diff options
| author | kennytm <kennytm@gmail.com> | 2017-12-20 21:22:00 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-20 21:22:00 +0800 |
| commit | 99fdca077c9e4b629dbb44453804ca0e449f0e56 (patch) | |
| tree | 74e5783462a6b2874e23f48a40996d1d164aa24c | |
| parent | 16095b3601a16262df8d96863b6235cba23a3f96 (diff) | |
| parent | e0e62fccd2572f80903e4e6b80891dfdb9242605 (diff) | |
| download | rust-99fdca077c9e4b629dbb44453804ca0e449f0e56.tar.gz rust-99fdca077c9e4b629dbb44453804ca0e449f0e56.zip | |
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.
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/issue-32950.stderr | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c3dd17e8775..74ec11b83c7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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` diff --git a/src/test/ui/issue-32950.stderr b/src/test/ui/issue-32950.stderr index 0933c81d655..abfa03f4d58 100644 --- a/src/test/ui/issue-32950.stderr +++ b/src/test/ui/issue-32950.stderr @@ -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 |
