rust/compiler/rustc_resolve/src
Michael Goulet 7e5528fa55
Rollup merge of #125795 - lucasscharenbroch:undescore-prefix-suggestion, r=compiler-errors
Improve renaming suggestion for names with leading underscores

Fixes #125650

Before:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
2 |     let _ = p;
  |             ^
  |
help: a local variable with a similar name exists, consider renaming `_p` into `p`
  |
1 | fn a(p: i32) {
  |      ~
```

After:
```
error[E0425]: cannot find value `p` in this scope
 --> test.rs:2:13
  |
1 | fn a(_p: i32) {
  |      -- `_p` defined here
2 |     let _ = p;
  |             ^
  |
help: the leading underscore in `_p` marks it as unused, consider renaming it to `p`
  |
1 | fn a(p: i32) {
  |      ~
```

This change doesn't exactly conform to what was proposed in the issue:

1. I've kept the suggested code instead of solely replacing it with the label
2. I've removed the "...similar name exists..." message instead of relocating to the usage span
3. You could argue that it still isn't completely clear that the change is referring to the definition (not the usage), but I'm not sure how to do this without playing down the fact that the error was caused by the usage of an undefined name.
2024-06-04 08:52:13 -04:00
..
late Rename HIR TypeBinding to AssocItemConstraint and related cleanup 2024-05-30 22:52:33 +02:00
build_reduced_graph.rs Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebank 2024-05-18 06:36:44 +00:00
check_unused.rs Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
def_collector.rs Create const block DefIds in typeck instead of ast lowering 2024-05-28 13:38:43 +00:00
diagnostics.rs Improve renaming suggestion for names with leading underscores 2024-05-30 21:39:12 -05:00
effective_visibilities.rs Auto merge of #125105 - nnethercote:rustc_resolve-cleanups, r=estebank 2024-05-18 06:36:44 +00:00
errors.rs Move "elided lifetime in path" to subdiagnostic struct 2024-04-21 07:45:03 +00:00
ident.rs Rename buffer_lint_with_diagnostic to buffer_lint 2024-05-21 20:16:39 +00:00
imports.rs Rollup merge of #125381 - estebank:issue-96799, r=petrochenkov 2024-05-29 03:25:08 +01:00
late.rs Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, r=compiler-errors 2024-05-31 08:50:22 +02:00
lib.rs Rollup merge of #125381 - estebank:issue-96799, r=petrochenkov 2024-05-29 03:25:08 +01:00
macros.rs Auto merge of #125326 - weiznich:move/do_not_recommend_to_diganostic_namespace, r=compiler-errors 2024-05-22 04:14:08 +00:00
rustdoc.rs Remove #[macro_use] extern crate tracing from rustc_resolve. 2024-05-10 15:34:41 +10:00