Account for missing . in macros to avoid incorrect suggestion

This commit is contained in:
Esteban Küber 2024-11-16 00:10:48 +00:00
parent 1ce0fa98c7
commit cbbc7becc8
2 changed files with 4 additions and 4 deletions

View file

@ -763,6 +763,10 @@ impl<'a> Parser<'a> {
} else { } else {
return; return;
} }
if self.token.span == self.prev_token.span {
// Account for syntax errors in proc-macros.
return;
}
if self.look_ahead(1, |t| [token::Semi, token::Question, token::Dot].contains(&t.kind)) { if self.look_ahead(1, |t| [token::Semi, token::Question, token::Dot].contains(&t.kind)) {
err.span_suggestion_verbose( err.span_suggestion_verbose(
self.prev_token.span.between(self.token.span), self.prev_token.span.between(self.token.span),

View file

@ -5,10 +5,6 @@ LL | make_bad_struct!(S);
| ^^^^^^^^^^^^^^^^^^^ expected one of 8 possible tokens | ^^^^^^^^^^^^^^^^^^^ expected one of 8 possible tokens
| |
= note: this error originates in the macro `make_bad_struct` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `make_bad_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to write a field access
|
LL | .;
| ~
error: aborting due to 1 previous error error: aborting due to 1 previous error