Rollup merge of #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 https://github.com/rust-lang-nursery/rustfmt/issues/2290.
This commit is contained in:
kennytm 2017-12-20 21:22:00 +08:00 committed by GitHub
commit 99fdca077c
2 changed files with 3 additions and 4 deletions

View File

@ -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`

View File

@ -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