From 4447949e400822a02cc9945fc39f06842e6b9439 Mon Sep 17 00:00:00 2001 From: SpanishPear Date: Sun, 22 Jan 2023 16:45:56 +1100 Subject: revert to previous span --- compiler/rustc_parse/src/parser/diagnostics.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_parse') diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 94bedc07ba1..9ac3bb946dc 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -352,11 +352,12 @@ impl<'a> Parser<'a> { // if there is a `<` after the fn name, then don't show a suggestion, show help if !self.look_ahead(1, |t| *t == token::Lt) && - let Ok(snippet) = self.sess.source_map().span_to_snippet(generic.span) { + let Ok(snippet) = self.sess.source_map().span_to_snippet(generic.span) && + let Ok(ident) = self.sess.source_map().span_to_snippet(self.token.span) { err.span_suggestion_verbose( - self.token.span.shrink_to_hi(), + generic.span.to(self.token.span), format!("place the generic parameter name after the {ident_name} name"), - snippet, + format!(" {ident}{snippet}"), Applicability::MaybeIncorrect, ); } else { -- cgit 1.4.1-3-g733a5