From 05bb22d9e86bcf4953ad2dbba36fa0adb6ebc859 Mon Sep 17 00:00:00 2001 From: holmgr Date: Wed, 10 Oct 2018 15:34:06 +0200 Subject: [PATCH] Remove incorrect span for second label inner macro invocation --- src/libsyntax/parse/parser.rs | 5 +++++ src/test/ui/macros/issue-54441.stderr | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d653ed819fd..08349084aa6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -772,6 +772,11 @@ impl<'a> Parser<'a> { // | 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"); diff --git a/src/test/ui/macros/issue-54441.stderr b/src/test/ui/macros/issue-54441.stderr index aa1edb2cf89..e27056b412a 100644 --- a/src/test/ui/macros/issue-54441.stderr +++ b/src/test/ui/macros/issue-54441.stderr @@ -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 ...