about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorSpanishPear <shrey.somaiya@gmail.com>2023-01-31 21:44:11 +1100
committerSpanishPear <shrey.somaiya@gmail.com>2023-01-31 21:44:11 +1100
commit70bfcc2518dc431cf20cd7d088b954fa348f17d9 (patch)
treeb21a45478c9e14cf425bd824d0f31f4d893b5d2c /compiler
parent8292d07cc4c9a070a9de808620bb79bab6935f70 (diff)
downloadrust-70bfcc2518dc431cf20cd7d088b954fa348f17d9.tar.gz
rust-70bfcc2518dc431cf20cd7d088b954fa348f17d9.zip
move to multipart spans
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index 9ac3bb946dc..1740f2c2c84 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -352,12 +352,13 @@ 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(ident) = self.sess.source_map().span_to_snippet(self.token.span) {
-                                    err.span_suggestion_verbose(
-                                        generic.span.to(self.token.span),
+                                let Ok(snippet) = self.sess.source_map().span_to_snippet(generic.span) {
+                                err.multipart_suggestion_verbose(
                                         format!("place the generic parameter name after the {ident_name} name"),
-                                        format!(" {ident}{snippet}"),
+                                        vec![
+                                            (self.token.span.shrink_to_hi(), snippet),
+                                            (generic.span, String::new())
+                                        ],
                                         Applicability::MaybeIncorrect,
                                     );
                                 } else {