about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-11-27 12:31:45 +0000
committerbors <bors@rust-lang.org>2018-11-27 12:31:45 +0000
commit10e2c729ea2e85cb1e2a08be40564492f49e45ec (patch)
tree20a10dec78680734dbac4325e578103c88858595 /src
parent691a7f8e2b2de984c3e0f062cbd294763af3d09a (diff)
parentd011313d843b3ddcf095db06907abffdd9cc5904 (diff)
downloadrust-10e2c729ea2e85cb1e2a08be40564492f49e45ec.tar.gz
rust-10e2c729ea2e85cb1e2a08be40564492f49e45ec.zip
Auto merge of #55402 - estebank:macro-eof-2, r=nikomatsakis
Point at end of macro arm when encountering EOF

Fix #52866.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_errors/diagnostic.rs11
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs24
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs44
-rw-r--r--src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs4
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.rs3
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.stderr2
-rw-r--r--src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr4
-rw-r--r--src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr4
-rw-r--r--src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr15
-rw-r--r--src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr15
-rw-r--r--src/test/ui/empty/empty-comment.stderr2
-rw-r--r--src/test/ui/fail-simple.stderr2
-rw-r--r--src/test/ui/issues/issue-7970a.stderr2
-rw-r--r--src/test/ui/issues/issue-7970b.stderr2
-rw-r--r--src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr6
-rw-r--r--src/test/ui/macros/macro-at-most-once-rep-2018.stderr26
-rw-r--r--src/test/ui/macros/macro-in-expression-context-2.stderr7
-rw-r--r--src/test/ui/macros/macro-non-lifetime.stderr2
-rw-r--r--src/test/ui/macros/missing-comma.stderr8
-rw-r--r--src/test/ui/macros/nonterminal-matching.stderr2
-rw-r--r--src/test/ui/macros/trace_faulty_macros.stderr2
-rw-r--r--src/test/ui/parser/macro/macro-doc-comments-1.stderr2
-rw-r--r--src/test/ui/parser/macro/macro-doc-comments-2.stderr2
-rw-r--r--src/test/ui/underscore-ident-matcher.stderr2
-rw-r--r--src/test/ui/vec/vec-macro-with-comma-only.stderr2
25 files changed, 130 insertions, 65 deletions
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index a323282f233..ea425ad4c47 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -139,6 +139,17 @@ impl Diagnostic {
         self
     }
 
+    pub fn replace_span_with(&mut self, after: Span) -> &mut Self {
+        let before = self.span.clone();
+        self.set_span(after);
+        for span_label in before.span_labels() {
+            if let Some(label) = span_label.label {
+                self.span_label(after, label);
+            }
+        }
+        self
+    }
+
     pub fn note_expected_found(&mut self,
                                label: &dyn fmt::Display,
                                expected: DiagnosticStyledString,
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index f31d80acbfa..8fd9590a664 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -281,7 +281,7 @@ pub enum ParseResult<T> {
     Success(T),
     /// Arm failed to match. If the second parameter is `token::Eof`, it indicates an unexpected
     /// end of macro invocation. Otherwise, it indicates that no rules expected the given token.
-    Failure(syntax_pos::Span, Token),
+    Failure(syntax_pos::Span, Token, String),
     /// Fatal error (malformed macro?). Abort compilation.
     Error(syntax_pos::Span, String),
 }
@@ -698,7 +698,7 @@ pub fn parse(
             parser.span,
         ) {
             Success(_) => {}
-            Failure(sp, tok) => return Failure(sp, tok),
+            Failure(sp, tok, t) => return Failure(sp, tok, t),
             Error(sp, msg) => return Error(sp, msg),
         }
 
@@ -710,7 +710,7 @@ pub fn parse(
         // Error messages here could be improved with links to original rules.
 
         // If we reached the EOF, check that there is EXACTLY ONE possible matcher. Otherwise,
-        // either the parse is ambiguous (which should never happen) or their is a syntax error.
+        // either the parse is ambiguous (which should never happen) or there is a syntax error.
         if token_name_eq(&parser.token, &token::Eof) {
             if eof_items.len() == 1 {
                 let matches = eof_items[0]
@@ -724,7 +724,15 @@ pub fn parse(
                     "ambiguity: multiple successful parses".to_string(),
                 );
             } else {
-                return Failure(parser.span, token::Eof);
+                return Failure(
+                    if parser.span.is_dummy() {
+                        parser.span
+                    } else {
+                        sess.source_map().next_point(parser.span)
+                    },
+                    token::Eof,
+                    "missing tokens in macro arguments".to_string(),
+                );
             }
         }
         // Performance hack: eof_items may share matchers via Rc with other things that we want
@@ -757,9 +765,13 @@ pub fn parse(
             );
         }
         // If there are no possible next positions AND we aren't waiting for the black-box parser,
-        // then their is a syntax error.
+        // then there is a syntax error.
         else if bb_items.is_empty() && next_items.is_empty() {
-            return Failure(parser.span, parser.token);
+            return Failure(
+                parser.span,
+                parser.token,
+                "no rules expected this token in macro call".to_string(),
+            );
         }
         // Dump all possible `next_items` into `cur_items` for the next iteration.
         else if !next_items.is_empty() {
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index d526e464ba4..ff622b0c18f 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -11,6 +11,7 @@
 use {ast, attr};
 use syntax_pos::{Span, DUMMY_SP};
 use edition::Edition;
+use errors::FatalError;
 use ext::base::{DummyResult, ExtCtxt, MacResult, SyntaxExtension};
 use ext::base::{NormalTT, TTMacroExpander};
 use ext::expand::{AstFragment, AstFragmentKind};
@@ -44,15 +45,34 @@ pub struct ParserAnyMacro<'a> {
     /// Span of the expansion site of the macro this parser is for
     site_span: Span,
     /// The ident of the macro we're parsing
-    macro_ident: ast::Ident
+    macro_ident: ast::Ident,
+    arm_span: Span,
 }
 
 impl<'a> ParserAnyMacro<'a> {
     pub fn make(mut self: Box<ParserAnyMacro<'a>>, kind: AstFragmentKind) -> AstFragment {
-        let ParserAnyMacro { site_span, macro_ident, ref mut parser } = *self;
+        let ParserAnyMacro { site_span, macro_ident, ref mut parser, arm_span } = *self;
         let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| {
+            if parser.token == token::Eof && e.message().ends_with(", found `<eof>`") {
+                if !e.span.is_dummy() {  // early end of macro arm (#52866)
+                    e.replace_span_with(parser.sess.source_map().next_point(parser.span));
+                }
+                let msg = &e.message[0];
+                e.message[0] = (
+                    format!(
+                        "macro expansion ends with an incomplete expression: {}",
+                        msg.0.replace(", found `<eof>`", ""),
+                    ),
+                    msg.1,
+                );
+            }
             if e.span.is_dummy() {  // Get around lack of span in error (#30128)
-                e.set_span(site_span);
+                e.replace_span_with(site_span);
+                if parser.sess.source_map().span_to_filename(arm_span).is_real() {
+                    e.span_label(arm_span, "in this macro arm");
+                }
+            } else if !parser.sess.source_map().span_to_filename(parser.span).is_real() {
+                e.span_label(site_span, "in this macro invocation");
             }
             e
         }));
@@ -120,6 +140,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
     // Which arm's failure should we report? (the one furthest along)
     let mut best_fail_spot = DUMMY_SP;
     let mut best_fail_tok = None;
+    let mut best_fail_text = None;
 
     for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers
         let lhs_tt = match *lhs {
@@ -134,6 +155,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
                     quoted::TokenTree::Delimited(_, ref delimed) => delimed.tts.clone(),
                     _ => cx.span_bug(sp, "malformed macro rhs"),
                 };
+                let arm_span = rhses[i].span();
 
                 let rhs_spans = rhs.iter().map(|t| t.span()).collect::<Vec<_>>();
                 // rhs has holes ( `$id` and `$(...)` that need filled)
@@ -172,12 +194,14 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
                     // so we can print a useful error message if the parse of the expanded
                     // macro leaves unparsed tokens.
                     site_span: sp,
-                    macro_ident: name
+                    macro_ident: name,
+                    arm_span,
                 })
             }
-            Failure(sp, tok) => if sp.lo() >= best_fail_spot.lo() {
+            Failure(sp, tok, t) => if sp.lo() >= best_fail_spot.lo() {
                 best_fail_spot = sp;
                 best_fail_tok = Some(tok);
+                best_fail_text = Some(t);
             },
             Error(err_sp, ref msg) => {
                 cx.span_fatal(err_sp.substitute_dummy(sp), &msg[..])
@@ -188,7 +212,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
     let best_fail_msg = parse_failure_msg(best_fail_tok.expect("ran no matchers"));
     let span = best_fail_spot.substitute_dummy(sp);
     let mut err = cx.struct_span_err(span, &best_fail_msg);
-    err.span_label(span, best_fail_msg);
+    err.span_label(span, best_fail_text.unwrap_or(best_fail_msg));
     if let Some(sp) = def_span {
         if cx.source_map().span_to_filename(sp).is_real() && !sp.is_dummy() {
             err.span_label(cx.source_map().def_span(sp), "when calling this macro");
@@ -268,9 +292,13 @@ pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item, edition:
 
     let argument_map = match parse(sess, body.stream(), &argument_gram, None, true) {
         Success(m) => m,
-        Failure(sp, tok) => {
+        Failure(sp, tok, t) => {
             let s = parse_failure_msg(tok);
-            sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s).raise();
+            let sp = sp.substitute_dummy(def.span);
+            let mut err = sess.span_diagnostic.struct_span_fatal(sp, &s);
+            err.span_label(sp, t);
+            err.emit();
+            FatalError.raise();
         }
         Error(sp, s) => {
             sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s).raise();
diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
index 2c5de332327..9f822834daf 100644
--- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
+++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
@@ -46,8 +46,8 @@ fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree])
                                     NodeId::from_u32(0));
     let map = match TokenTree::parse(cx, &mbe_matcher, args.iter().cloned().collect()) {
         Success(map) => map,
-        Failure(_, tok) => {
-            panic!("expected Success, but got Failure: {}", parse_failure_msg(tok));
+        Failure(_, tok, msg) => {
+            panic!("expected Success, but got Failure: {} - {}", parse_failure_msg(tok), msg);
         }
         Error(_, s) => {
             panic!("expected Success, but got Error: {}", s);
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs
index 8e631a64f7a..59ebc94f6de 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.rs
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs
@@ -19,5 +19,6 @@ mod macro_expanded_mod_helper {
 }
 
 fn main() {
-    mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block
+    mod_decl!(foo);
+    //~^ ERROR Cannot declare a non-inline module inside a block
 }
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
index a9efcd883c1..43bf720083d 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
@@ -1,7 +1,7 @@
 error: Cannot declare a non-inline module inside a block unless it has a path attribute
   --> $DIR/macro-expanded-mod.rs:22:15
    |
-LL |     mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block
+LL |     mod_decl!(foo);
    |               ^^^
 
 error: aborting due to previous error
diff --git a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr
index e8f05cbb0ef..8bf8c3c3560 100644
--- a/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2015-2015-parsing.stderr
@@ -2,13 +2,13 @@ error: no rules expected the token `r#async`
   --> $DIR/edition-keywords-2015-2015-parsing.rs:22:31
    |
 LL |     r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
-   |                               ^^^^^^^ no rules expected the token `r#async`
+   |                               ^^^^^^^ no rules expected this token in macro call
 
 error: no rules expected the token `async`
   --> $DIR/edition-keywords-2015-2015-parsing.rs:23:35
    |
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
-   |                                   ^^^^^ no rules expected the token `async`
+   |                                   ^^^^^ no rules expected this token in macro call
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr
index 3f5e1137383..77622548bce 100644
--- a/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2015-2018-parsing.stderr
@@ -2,13 +2,13 @@ error: no rules expected the token `r#async`
   --> $DIR/edition-keywords-2015-2018-parsing.rs:22:31
    |
 LL |     r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
-   |                               ^^^^^^^ no rules expected the token `r#async`
+   |                               ^^^^^^^ no rules expected this token in macro call
 
 error: no rules expected the token `async`
   --> $DIR/edition-keywords-2015-2018-parsing.rs:23:35
    |
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
-   |                                   ^^^^^ no rules expected the token `async`
+   |                                   ^^^^^ no rules expected this token in macro call
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
index b6ff60f1492..d0edc368ad5 100644
--- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr
@@ -14,19 +14,24 @@ error: no rules expected the token `r#async`
   --> $DIR/edition-keywords-2018-2015-parsing.rs:22:31
    |
 LL |     r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
-   |                               ^^^^^^^ no rules expected the token `r#async`
+   |                               ^^^^^^^ no rules expected this token in macro call
 
 error: no rules expected the token `async`
   --> $DIR/edition-keywords-2018-2015-parsing.rs:23:35
    |
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
-   |                                   ^^^^^ no rules expected the token `async`
+   |                                   ^^^^^ no rules expected this token in macro call
 
-error: expected one of `move`, `|`, or `||`, found `<eof>`
-  --> <::edition_kw_macro_2015::passes_ident macros>:1:22
+error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||`
+  --> <::edition_kw_macro_2015::passes_ident macros>:1:25
    |
 LL | ( $ i : ident ) => ( $ i )
-   |                      ^^^ expected one of `move`, `|`, or `||` here
+   |                         ^ expected one of `move`, `|`, or `||` here
+   | 
+  ::: $DIR/edition-keywords-2018-2015-parsing.rs:26:8
+   |
+LL |     if passes_ident!(async) == 1 {}
+   |        -------------------- in this macro invocation
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
index ffe666a7e64..c4e1e0257c5 100644
--- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
+++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr
@@ -14,19 +14,24 @@ error: no rules expected the token `r#async`
   --> $DIR/edition-keywords-2018-2018-parsing.rs:22:31
    |
 LL |     r#async = consumes_async!(r#async); //~ ERROR no rules expected the token `r#async`
-   |                               ^^^^^^^ no rules expected the token `r#async`
+   |                               ^^^^^^^ no rules expected this token in macro call
 
 error: no rules expected the token `async`
   --> $DIR/edition-keywords-2018-2018-parsing.rs:23:35
    |
 LL |     r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async`
-   |                                   ^^^^^ no rules expected the token `async`
+   |                                   ^^^^^ no rules expected this token in macro call
 
-error: expected one of `move`, `|`, or `||`, found `<eof>`
-  --> <::edition_kw_macro_2018::passes_ident macros>:1:22
+error: macro expansion ends with an incomplete expression: expected one of `move`, `|`, or `||`
+  --> <::edition_kw_macro_2018::passes_ident macros>:1:25
    |
 LL | ( $ i : ident ) => ( $ i )
-   |                      ^^^ expected one of `move`, `|`, or `||` here
+   |                         ^ expected one of `move`, `|`, or `||` here
+   | 
+  ::: $DIR/edition-keywords-2018-2018-parsing.rs:26:8
+   |
+LL |     if passes_ident!(async) == 1 {}
+   |        -------------------- in this macro invocation
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/empty/empty-comment.stderr b/src/test/ui/empty/empty-comment.stderr
index de826102081..d1b031c1f6c 100644
--- a/src/test/ui/empty/empty-comment.stderr
+++ b/src/test/ui/empty/empty-comment.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! one_arg_macro {
    | -------------------------- when calling this macro
 ...
 LL |     one_arg_macro!(/**/); //~ ERROR unexpected end
-   |     ^^^^^^^^^^^^^^^^^^^^^ unexpected end of macro invocation
+   |     ^^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/fail-simple.stderr b/src/test/ui/fail-simple.stderr
index 4a4aec5b6ac..9759249342a 100644
--- a/src/test/ui/fail-simple.stderr
+++ b/src/test/ui/fail-simple.stderr
@@ -2,7 +2,7 @@ error: no rules expected the token `@`
   --> $DIR/fail-simple.rs:12:12
    |
 LL |     panic!(@); //~ ERROR no rules expected the token `@`
-   |            ^ no rules expected the token `@`
+   |            ^ no rules expected this token in macro call
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-7970a.stderr b/src/test/ui/issues/issue-7970a.stderr
index 96fb374b58c..2e2e869199c 100644
--- a/src/test/ui/issues/issue-7970a.stderr
+++ b/src/test/ui/issues/issue-7970a.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! one_arg_macro {
    | -------------------------- when calling this macro
 ...
 LL |     one_arg_macro!();
-   |     ^^^^^^^^^^^^^^^^^ unexpected end of macro invocation
+   |     ^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-7970b.stderr b/src/test/ui/issues/issue-7970b.stderr
index b2feb677863..d49544e6c1e 100644
--- a/src/test/ui/issues/issue-7970b.stderr
+++ b/src/test/ui/issues/issue-7970b.stderr
@@ -2,7 +2,7 @@ error: unexpected end of macro invocation
   --> $DIR/issue-7970b.rs:13:1
    |
 LL | macro_rules! test {}
-   | ^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr
index 7705ba3b11e..27dc03e1c39 100644
--- a/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr
+++ b/src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.stderr
@@ -55,7 +55,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:42:11
@@ -64,7 +64,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?a); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018-feature-gate.rs:43:11
@@ -73,7 +73,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?a?a); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: aborting due to 10 previous errors
 
diff --git a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
index 25dd66b81f5..d363b672680 100644
--- a/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
+++ b/src/test/ui/macros/macro-at-most-once-rep-2018.stderr
@@ -11,7 +11,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:37:11
@@ -20,7 +20,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?a); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:38:11
@@ -29,7 +29,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a?a?a); //~ ERROR no rules expected the token `?`
-   |           ^ no rules expected the token `?`
+   |           ^ no rules expected this token in macro call
 
 error: unexpected end of macro invocation
   --> $DIR/macro-at-most-once-rep-2018.rs:40:5
@@ -38,16 +38,16 @@ LL | macro_rules! barplus {
    | -------------------- when calling this macro
 ...
 LL |     barplus!(); //~ERROR unexpected end of macro invocation
-   |     ^^^^^^^^^^^ unexpected end of macro invocation
+   |     ^^^^^^^^^^^ missing tokens in macro arguments
 
 error: unexpected end of macro invocation
-  --> $DIR/macro-at-most-once-rep-2018.rs:41:14
+  --> $DIR/macro-at-most-once-rep-2018.rs:41:15
    |
 LL | macro_rules! barplus {
    | -------------------- when calling this macro
 ...
 LL |     barplus!(a); //~ERROR unexpected end of macro invocation
-   |              ^ unexpected end of macro invocation
+   |               ^ missing tokens in macro arguments
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:42:15
@@ -56,7 +56,7 @@ LL | macro_rules! barplus {
    | -------------------- when calling this macro
 ...
 LL |     barplus!(a?); //~ ERROR no rules expected the token `?`
-   |               ^ no rules expected the token `?`
+   |               ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:43:15
@@ -65,7 +65,7 @@ LL | macro_rules! barplus {
    | -------------------- when calling this macro
 ...
 LL |     barplus!(a?a); //~ ERROR no rules expected the token `?`
-   |               ^ no rules expected the token `?`
+   |               ^ no rules expected this token in macro call
 
 error: unexpected end of macro invocation
   --> $DIR/macro-at-most-once-rep-2018.rs:47:5
@@ -74,16 +74,16 @@ LL | macro_rules! barstar {
    | -------------------- when calling this macro
 ...
 LL |     barstar!(); //~ERROR unexpected end of macro invocation
-   |     ^^^^^^^^^^^ unexpected end of macro invocation
+   |     ^^^^^^^^^^^ missing tokens in macro arguments
 
 error: unexpected end of macro invocation
-  --> $DIR/macro-at-most-once-rep-2018.rs:48:14
+  --> $DIR/macro-at-most-once-rep-2018.rs:48:15
    |
 LL | macro_rules! barstar {
    | -------------------- when calling this macro
 ...
 LL |     barstar!(a); //~ERROR unexpected end of macro invocation
-   |              ^ unexpected end of macro invocation
+   |               ^ missing tokens in macro arguments
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:49:15
@@ -92,7 +92,7 @@ LL | macro_rules! barstar {
    | -------------------- when calling this macro
 ...
 LL |     barstar!(a?); //~ ERROR no rules expected the token `?`
-   |               ^ no rules expected the token `?`
+   |               ^ no rules expected this token in macro call
 
 error: no rules expected the token `?`
   --> $DIR/macro-at-most-once-rep-2018.rs:50:15
@@ -101,7 +101,7 @@ LL | macro_rules! barstar {
    | -------------------- when calling this macro
 ...
 LL |     barstar!(a?a); //~ ERROR no rules expected the token `?`
-   |               ^ no rules expected the token `?`
+   |               ^ no rules expected this token in macro call
 
 error: aborting due to 12 previous errors
 
diff --git a/src/test/ui/macros/macro-in-expression-context-2.stderr b/src/test/ui/macros/macro-in-expression-context-2.stderr
index 80d5dbd66cc..672871c49ca 100644
--- a/src/test/ui/macros/macro-in-expression-context-2.stderr
+++ b/src/test/ui/macros/macro-in-expression-context-2.stderr
@@ -1,8 +1,11 @@
-error: expected expression, found `<eof>`
+error: macro expansion ends with an incomplete expression: expected expression
   --> $DIR/macro-in-expression-context-2.rs:5:16
    |
+LL | macro_rules! empty { () => () }
+   |                            -- in this macro arm
+...
 LL |         _ => { empty!() }
-   |                ^^^^^^^^
+   |                ^^^^^^^^ expected expression
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/macros/macro-non-lifetime.stderr b/src/test/ui/macros/macro-non-lifetime.stderr
index d526023d441..df9db06ca19 100644
--- a/src/test/ui/macros/macro-non-lifetime.stderr
+++ b/src/test/ui/macros/macro-non-lifetime.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! m { ($x:lifetime) => { } }
    | -------------- when calling this macro
 ...
 LL |     m!(a);
-   |        ^ no rules expected the token `a`
+   |        ^ no rules expected this token in macro call
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr
index 1d6af44bd08..886e15c4412 100644
--- a/src/test/ui/macros/missing-comma.stderr
+++ b/src/test/ui/macros/missing-comma.stderr
@@ -11,7 +11,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a b);
-   |           -^ no rules expected the token `b`
+   |           -^ no rules expected this token in macro call
    |           |
    |           help: missing comma here
 
@@ -22,7 +22,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a, b, c, d e);
-   |                    -^ no rules expected the token `e`
+   |                    -^ no rules expected this token in macro call
    |                    |
    |                    help: missing comma here
 
@@ -33,7 +33,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a, b, c d, e);
-   |                 -^ no rules expected the token `d`
+   |                 -^ no rules expected this token in macro call
    |                 |
    |                 help: missing comma here
 
@@ -44,7 +44,7 @@ LL | macro_rules! foo {
    | ---------------- when calling this macro
 ...
 LL |     foo!(a, b, c d e);
-   |                  ^ no rules expected the token `d`
+   |                  ^ no rules expected this token in macro call
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/macros/nonterminal-matching.stderr b/src/test/ui/macros/nonterminal-matching.stderr
index 23853978d37..9dfa53dab55 100644
--- a/src/test/ui/macros/nonterminal-matching.stderr
+++ b/src/test/ui/macros/nonterminal-matching.stderr
@@ -2,7 +2,7 @@ error: no rules expected the token `enum E { }`
   --> $DIR/nonterminal-matching.rs:29:10
    |
 LL |     n!(a $nt_item b); //~ ERROR no rules expected the token `enum E { }`
-   |          ^^^^^^^^ no rules expected the token `enum E { }`
+   |          ^^^^^^^^ no rules expected this token in macro call
 ...
 LL | complex_nonterminal!(enum E {});
    | -------------------------------- in this macro invocation
diff --git a/src/test/ui/macros/trace_faulty_macros.stderr b/src/test/ui/macros/trace_faulty_macros.stderr
index 853eb5847c0..f524ebb3216 100644
--- a/src/test/ui/macros/trace_faulty_macros.stderr
+++ b/src/test/ui/macros/trace_faulty_macros.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! my_faulty_macro {
    | ---------------------------- when calling this macro
 LL |     () => {
 LL |         my_faulty_macro!(bcd); //~ ERROR no rules
-   |                          ^^^ no rules expected the token `bcd`
+   |                          ^^^ no rules expected this token in macro call
 ...
 LL |     my_faulty_macro!();
    |     ------------------- in this macro invocation
diff --git a/src/test/ui/parser/macro/macro-doc-comments-1.stderr b/src/test/ui/parser/macro/macro-doc-comments-1.stderr
index 1e765dcde4f..c40a7badaac 100644
--- a/src/test/ui/parser/macro/macro-doc-comments-1.stderr
+++ b/src/test/ui/parser/macro/macro-doc-comments-1.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! outer {
    | ------------------ when calling this macro
 ...
 LL |     //! Inner
-   |     ^^^^^^^^^ no rules expected the token `!`
+   |     ^^^^^^^^^ no rules expected this token in macro call
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/parser/macro/macro-doc-comments-2.stderr b/src/test/ui/parser/macro/macro-doc-comments-2.stderr
index 0ab8a3cafb5..7bdd432808c 100644
--- a/src/test/ui/parser/macro/macro-doc-comments-2.stderr
+++ b/src/test/ui/parser/macro/macro-doc-comments-2.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! inner {
    | ------------------ when calling this macro
 ...
 LL |     /// Outer
-   |     ^ no rules expected the token `[`
+   |     ^ no rules expected this token in macro call
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/underscore-ident-matcher.stderr b/src/test/ui/underscore-ident-matcher.stderr
index e148c48ed13..171e81e2d87 100644
--- a/src/test/ui/underscore-ident-matcher.stderr
+++ b/src/test/ui/underscore-ident-matcher.stderr
@@ -5,7 +5,7 @@ LL | macro_rules! identity {
    | --------------------- when calling this macro
 ...
 LL |     let identity!(_) = 10; //~ ERROR no rules expected the token `_`
-   |                   ^ no rules expected the token `_`
+   |                   ^ no rules expected this token in macro call
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/vec/vec-macro-with-comma-only.stderr b/src/test/ui/vec/vec-macro-with-comma-only.stderr
index 856d85ef5cd..74f5d2326ac 100644
--- a/src/test/ui/vec/vec-macro-with-comma-only.stderr
+++ b/src/test/ui/vec/vec-macro-with-comma-only.stderr
@@ -2,7 +2,7 @@ error: no rules expected the token `,`
   --> $DIR/vec-macro-with-comma-only.rs:12:10
    |
 LL |     vec![,]; //~ ERROR no rules expected the token `,`
-   |          ^ no rules expected the token `,`
+   |          ^ no rules expected this token in macro call
 
 error: aborting due to previous error