diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-11-16 00:10:48 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-12-21 02:46:33 +0000 |
| commit | cbbc7becc820e05f64d8a23d1a63a27e51b8ff7a (patch) | |
| tree | ec4dea59fa06072ef2bbb385525f8efbb0d973fe | |
| parent | 1ce0fa98c7766dc9e168b92ff9bc4e0df4fcaaef (diff) | |
| download | rust-cbbc7becc820e05f64d8a23d1a63a27e51b8ff7a.tar.gz rust-cbbc7becc820e05f64d8a23d1a63a27e51b8ff7a.zip | |
Account for missing `.` in macros to avoid incorrect suggestion
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 4 | ||||
| -rw-r--r-- | tests/ui/proc-macro/raw-ident.stderr | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 259bc3dcd36..30a150db728 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -763,6 +763,10 @@ impl<'a> Parser<'a> { } else { 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)) { err.span_suggestion_verbose( self.prev_token.span.between(self.token.span), diff --git a/tests/ui/proc-macro/raw-ident.stderr b/tests/ui/proc-macro/raw-ident.stderr index 32b36c6d989..a72067021cb 100644 --- a/tests/ui/proc-macro/raw-ident.stderr +++ b/tests/ui/proc-macro/raw-ident.stderr @@ -5,10 +5,6 @@ LL | make_bad_struct!(S); | ^^^^^^^^^^^^^^^^^^^ 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) -help: you might have meant to write a field access - | -LL | .; - | ~ error: aborting due to 1 previous error |
