1
Fork 0

revert to previous span

This commit is contained in:
SpanishPear 2023-01-22 16:45:56 +11:00
parent 655beb4ece
commit 4447949e40
7 changed files with 10 additions and 9 deletions

View file

@ -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 there is a `<` after the fn name, then don't show a suggestion, show help
if !self.look_ahead(1, |t| *t == token::Lt) && 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( 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"), format!("place the generic parameter name after the {ident_name} name"),
snippet, format!(" {ident}{snippet}"),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
); );
} else { } else {

View file

@ -7,7 +7,7 @@ LL | enum<T> Foo { Variant(T) }
help: place the generic parameter name after the enum name help: place the generic parameter name after the enum name
| |
LL | enum Foo<T> { Variant(T) } LL | enum Foo<T> { Variant(T) }
| ~~~ | ~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | fn<'a, B: 'a + std::ops::Add<Output = u32>> f(_x: B) { }
help: place the generic parameter name after the fn name help: place the generic parameter name after the fn name
| |
LL | fn f<'a, B: 'a + std::ops::Add<Output = u32>>(_x: B) { } LL | fn f<'a, B: 'a + std::ops::Add<Output = u32>>(_x: B) { }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | fn<T> id(x: T) -> T { x }
help: place the generic parameter name after the fn name help: place the generic parameter name after the fn name
| |
LL | fn id<T>(x: T) -> T { x } LL | fn id<T>(x: T) -> T { x }
| ~~~ | ~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | struct<T> Foo { x: T }
help: place the generic parameter name after the struct name help: place the generic parameter name after the struct name
| |
LL | struct Foo<T> { x: T } LL | struct Foo<T> { x: T }
| ~~~ | ~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | trait<T> Foo {
help: place the generic parameter name after the trait name help: place the generic parameter name after the trait name
| |
LL | trait Foo<T> { LL | trait Foo<T> {
| ~~~ | ~~~~~~
error: aborting due to previous error error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | type<T> Foo = T;
help: place the generic parameter name after the type name help: place the generic parameter name after the type name
| |
LL | type Foo<T> = T; LL | type Foo<T> = T;
| ~~~ | ~~~~~~
error: aborting due to previous error error: aborting due to previous error