Trevor Gross
3d3d898a2e
Rollup merge of #133486 - dianne:fix-move-error-suggestion, r=estebank
...
borrowck diagnostics: make `add_move_error_suggestions` use the HIR rather than `SourceMap`
This PR aims to fix #132806 by rewriting `add_move_error_suggestions`[^1]. Previously, it manually scanned the source text to find a leading `&`, which isn't always going to produce a correct result (see: that issue). Admittedly, the HIR visitor in this PR introduces a lot of boilerplate, but hopefully the logic at its core isn't too complicated (I go over it in the comments). I also tried a simpler version that didn't use a HIR visitor and suggested adding `ref` always, but the `&ref x` suggestions really didn't look good. As a bonus for the added complexity though, it's now able to produce nice `&`-removing suggestions in more cases.
I tried to do this such that it avoids edition-dependent checks and its suggestions can be applied together with those from the match ergonomics 2024 migration lint. I haven't added tests for that since the details of match ergonomics 2024 are still being sorted out, but I can try if desired once that's finalized.
[^1]: In brief, it fires on patterns where users try to bind by-value in such a way that moves out of a reference to a non-Copy type (including slice references with non-copy elements). The suggestions are to change the binding's mode to be by-reference, either by removing[^2] an enclosing `&`/`&mut` or adding `ref` to the binding.
[^2]: Incidentally, I find the terminology of "consider removing the borrow" a bit confusing for a suggestion to remove a `&` pattern in order to make bindings borrow rather than move. I'm not sure what a good, concise way to explain that would be though, and that should go in a separate PR anyway.
2024-12-31 18:42:23 -05:00
..
2024-12-12 23:36:27 +00:00
2024-08-17 12:43:25 -04:00
2024-08-17 12:43:25 -04:00
2024-02-29 15:27:59 -03:00
2024-12-03 17:26:43 +01:00
2024-11-21 01:35:34 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-18 06:01:40 +03:00
2024-09-13 14:10:56 +03:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-04-11 16:41:41 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-13 16:00:01 +00:00
2024-02-13 16:00:01 +00:00
2024-07-26 14:41:56 -04:00
2024-04-24 22:21:13 +00:00
2024-07-04 05:36:34 +00:00
2024-02-16 20:02:50 +00:00
2023-10-05 01:04:41 +00:00
2024-04-12 04:46:31 +00:00
2024-04-12 04:46:31 +00:00
2024-04-12 04:46:31 +00:00
2024-04-12 04:46:31 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-08 08:10:43 +00:00
2024-02-08 08:10:43 +00:00
2024-04-24 08:05:29 +00:00
2024-04-24 08:05:29 +00:00
2024-07-04 05:36:34 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-24 08:05:29 +00:00
2023-11-24 21:04:51 +01:00
2023-07-10 20:09:26 +00:00
2023-08-06 21:20:15 +02:00
2023-08-06 21:20:15 +02:00
2024-03-23 16:14:42 +01:00
2024-03-23 12:50:21 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-24 22:21:15 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-26 14:41:56 -04:00
2024-07-26 14:41:56 -04:00
2024-07-26 14:41:56 -04:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-07-26 14:41:56 -04:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-05-08 17:58:01 -03:00
2023-11-24 19:15:52 +01:00
2023-05-08 17:58:01 -03:00
2023-11-24 19:15:52 +01:00
2023-05-08 17:58:01 -03:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-04-07 17:38:07 -03:00
2024-04-07 17:38:07 -03:00
2024-04-07 17:38:07 -03:00
2024-04-07 17:38:07 -03:00
2024-04-07 17:38:07 -03:00
2024-04-07 17:38:07 -03:00
2024-04-24 22:21:13 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-04 05:36:34 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-04-24 08:05:29 +00:00
2024-04-24 08:05:29 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-07-10 20:09:26 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-26 14:41:56 -04:00
2024-02-16 20:02:50 +00:00
2024-04-11 16:41:41 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-06-18 04:14:43 +08:00
2023-11-24 19:15:52 +01:00
2024-04-11 16:41:41 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-03-10 21:18:41 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-03-20 13:00:34 -04:00
2024-03-20 13:00:34 -04:00
2023-05-08 17:58:01 -03:00
2023-05-08 17:58:01 -03:00
2023-05-08 17:58:01 -03:00
2023-12-15 06:59:42 +00:00
2023-11-24 19:15:52 +01:00
2024-11-28 14:32:45 -08:00
2024-11-28 14:32:45 -08:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-09-24 22:20:46 +02:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-05-03 15:56:59 +02:00
2024-05-03 15:56:59 +02:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-24 08:05:29 +00:00
2024-07-21 22:32:29 -04:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-21 15:43:43 -03:00
2024-04-21 15:43:43 -03:00
2024-04-21 20:10:12 -04:00
2024-04-21 20:10:12 -04:00
2024-04-21 20:10:12 -04:00
2024-04-21 20:10:12 -04:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-05-05 22:40:05 +12:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-07-10 20:09:26 +00:00
2023-07-10 20:09:26 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-09-13 14:10:56 +03:00
2024-09-13 14:10:56 +03:00
2023-11-24 19:15:52 +01:00
2024-08-17 12:43:25 -04:00
2023-02-16 11:42:35 -03:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-10-05 01:04:41 +00:00
2024-02-16 20:02:50 +00:00
2023-10-08 10:06:17 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-07-10 20:09:26 +00:00
2024-04-03 21:02:47 +02:00
2024-04-03 21:02:47 +02:00
2024-04-03 23:16:27 +02:00
2024-04-10 20:36:14 +00:00
2024-07-26 14:41:56 -04:00
2024-07-26 14:41:56 -04:00
2024-04-15 21:36:52 -04:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-03-14 17:19:40 +01:00
2024-03-14 17:19:40 +01:00
2024-11-25 20:29:04 -08:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-14 11:00:30 +00:00
2024-02-14 11:00:30 +00:00
2024-02-16 20:02:50 +00:00
2023-02-22 08:40:47 -07:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2024-12-12 23:36:27 +00:00
2023-12-07 23:00:46 -05:00
2023-10-05 01:04:41 +00:00
2024-03-24 10:05:27 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-11-24 19:15:52 +01:00