Skip to content

Commit

Permalink
Rollup merge of rust-lang#46835 - topecongiro:bad-span-for-macro-invo…
Browse files Browse the repository at this point in the history
…cation-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.
  • Loading branch information
kennytm committed Dec 20, 2017
2 parents 16095b3 + e0e62fc commit 99fdca0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ impl<'a> Parser<'a> {
if self.eat(&token::Not) {
// Macro invocation in type position
let (_, tts) = self.expect_delimited_token_tree()?;
TyKind::Mac(respan(lo.to(self.span), Mac_ { path: path, tts: tts }))
TyKind::Mac(respan(lo.to(self.prev_span), Mac_ { path: path, tts: tts }))
} else {
// Just a type path or bound list (trait object type) starting with a trait.
// `Type`
Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/issue-32950.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
error: `derive` cannot be used on items with type macros
--> $DIR/issue-32950.rs:15:5
|
15 | / concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
16 | | );
| |_^
15 | concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros
| ^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

0 comments on commit 99fdca0

Please sign in to comment.