Skip to content

Commit 644dbf9

Browse files
authored
Rollup merge of rust-lang#54967 - holmgr:master, r=estebank
Remove incorrect span for second label inner macro invocation A fix for issue rust-lang#54841
2 parents 0187e81 + 05bb22d commit 644dbf9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: src/libsyntax/parse/parser.rs

+5
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,11 @@ impl<'a> Parser<'a> {
772772
// | expected one of 8 possible tokens here
773773
err.span_label(self.span, label_exp);
774774
}
775+
_ if self.prev_span == syntax_pos::DUMMY_SP => {
776+
// Account for macro context where the previous span might not be
777+
// available to avoid incorrect output (#54841).
778+
err.span_label(self.span, "unexpected token");
779+
}
775780
_ => {
776781
err.span_label(sp, label_exp);
777782
err.span_label(self.span, "unexpected token");

Diff for: src/test/ui/macros/issue-54441.stderr

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found `let`
22
--> $DIR/issue-54441.rs:5:9
33
|
4-
LL | #![feature(macros_in_extern)]
5-
| - expected one of `crate`, `fn`, `pub`, `static`, or `type` here
6-
...
74
LL | let //~ ERROR expected
85
| ^^^ unexpected token
96
...

0 commit comments

Comments
 (0)