Skip to content

Commit 99fdca0

Browse files
authored
Rollup merge of rust-lang#46835 - topecongiro:bad-span-for-macro-invocation-in-type, r=petrochenkov
Remove a token after closing delimiter from the span of macro in type position e.g. ```rust let x = y: foo!(); ``` The span for `foo!()` includes `;`. cc rust-lang/rustfmt#2290.
2 parents 16095b3 + e0e62fc commit 99fdca0

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ impl<'a> Parser<'a> {
15531553
if self.eat(&token::Not) {
15541554
// Macro invocation in type position
15551555
let (_, tts) = self.expect_delimited_token_tree()?;
1556-
TyKind::Mac(respan(lo.to(self.span), Mac_ { path: path, tts: tts }))
1556+
TyKind::Mac(respan(lo.to(self.prev_span), Mac_ { path: path, tts: tts }))
15571557
} else {
15581558
// Just a type path or bound list (trait object type) starting with a trait.
15591559
// `Type`

src/test/ui/issue-32950.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
error: `derive` cannot be used on items with type macros
22
--> $DIR/issue-32950.rs:15:5
33
|
4-
15 | / concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
5-
16 | | );
6-
| |_^
4+
15 | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
76

87
error: aborting due to previous error
98

0 commit comments

Comments
 (0)