From 3770cf7abf2c62667e8b197be1bea3665e75a8f1 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 29 Feb 2024 12:06:51 +0100 Subject: [PATCH] Improve suggestion to rename type starting with underscore to make it more obvious what is actually suggested --- compiler/rustc_resolve/src/diagnostics.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 222dd69dbc4..6e8499be9e8 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1571,9 +1571,10 @@ pub(crate) fn add_typo_suggestion( { // 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!(