move to multipart spans

This commit is contained in:
SpanishPear 2023-01-31 21:44:11 +11:00
parent 8292d07cc4
commit 70bfcc2518
7 changed files with 24 additions and 17 deletions

View file

@ -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 {