]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #54967 - holmgr:master, r=estebank
authorkennytm <kennytm@gmail.com>
Fri, 12 Oct 2018 14:04:16 +0000 (22:04 +0800)
committerGitHub <noreply@github.com>
Fri, 12 Oct 2018 14:04:16 +0000 (22:04 +0800)
Remove incorrect span for second label inner macro invocation

A fix for issue #54841

src/libsyntax/parse/parser.rs
src/test/ui/macros/issue-54441.stderr

index 6c375799c38ad5cd83cbf1cc33e9bd5f8652318e..b5896f37c00b8b11eba35ac4798c7440e8bc5f2a 100644 (file)
@@ -772,6 +772,11 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
                     //   |                   expected one of 8 possible tokens here
                     err.span_label(self.span, label_exp);
                 }
+                _ if self.prev_span == syntax_pos::DUMMY_SP => {
+                    // Account for macro context where the previous span might not be
+                    // available to avoid incorrect output (#54841).
+                    err.span_label(self.span, "unexpected token");
+                }
                 _ => {
                     err.span_label(sp, label_exp);
                     err.span_label(self.span, "unexpected token");
index aa1edb2cf893fdd26ed2b99911ad8a5caf95c594..e27056b412a0fb5383b93ba47d5642133f8d5011 100644 (file)
@@ -1,9 +1,6 @@
 error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found `let`
   --> $DIR/issue-54441.rs:5:9
    |
-LL | #![feature(macros_in_extern)]
-   | - expected one of `crate`, `fn`, `pub`, `static`, or `type` here
-...
 LL |         let //~ ERROR expected
    |         ^^^ unexpected token
 ...