about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorSpanishPear <shrey.somaiya@gmail.com>2023-01-22 16:45:56 +1100
committerSpanishPear <shrey.somaiya@gmail.com>2023-01-22 17:05:38 +1100
commit4447949e400822a02cc9945fc39f06842e6b9439 (patch)
tree503b7041c6655c961f99c7df01f4232312d6f067 /compiler/rustc_parse/src/parser
parent655beb4ece8a116c664ae63f26811ba75aa9e0e7 (diff)
downloadrust-4447949e400822a02cc9945fc39f06842e6b9439.tar.gz
rust-4447949e400822a02cc9945fc39f06842e6b9439.zip
revert to previous span
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs7
1 files changed, 4 insertions, 3 deletions
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 {