diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index e4298a981292a..6b45db7ba8323 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1585,9 +1585,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { { // When the suggested binding change would be from `x` to `_x`, suggest changing the // original binding definition instead. (#60164) - (span, snippet, ", consider changing it") + let post = format!(", consider renaming `{}` into `{snippet}`", suggestion.candidate); + (span, snippet, post) } else { - (span, suggestion.candidate.to_string(), "") + (span, suggestion.candidate.to_string(), String::new()) }; let msg = match suggestion.target { SuggestionTarget::SimilarlyNamed => format!( diff --git a/tests/ui/suggestions/silenced-binding-typo.stderr b/tests/ui/suggestions/silenced-binding-typo.stderr index 8dbd94208d614..c362d00c713a2 100644 --- a/tests/ui/suggestions/silenced-binding-typo.stderr +++ b/tests/ui/suggestions/silenced-binding-typo.stderr @@ -4,7 +4,7 @@ error[E0425]: cannot find value `x` in this scope LL | let _y = x; | ^ | -help: a local variable with a similar name exists, consider changing it +help: a local variable with a similar name exists, consider renaming `_x` into `x` | LL | let x = 42; | ~