Skip to content

Commit 4221ce9

Browse files
committed
Account for missing . in macros to avoid incorrect suggestion
1 parent 3879927 commit 4221ce9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_parse/src/parser/stmt.rs

+4
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ impl<'a> Parser<'a> {
748748
} else {
749749
return;
750750
}
751+
if self.token.span == self.prev_token.span {
752+
// Account for syntax errors in proc-macros.
753+
return;
754+
}
751755
if self.look_ahead(1, |t| [token::Semi, token::Question, token::Dot].contains(&t.kind)) {
752756
err.span_suggestion_verbose(
753757
self.prev_token.span.between(self.token.span),

tests/ui/proc-macro/raw-ident.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ LL | make_bad_struct!(S);
55
| ^^^^^^^^^^^^^^^^^^^ expected one of 8 possible tokens
66
|
77
= note: this error originates in the macro `make_bad_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
8-
help: you might have meant to write a field access
9-
|
10-
LL | .;
11-
| ~
128

139
error: aborting due to 1 previous error
1410

0 commit comments

Comments
 (0)