From ea9ccb6046aa1733aa1761fc942f8432fb63f107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 25 Oct 2018 10:09:19 -0700 Subject: [PATCH 1/7] Point at end of macro arm when encountering EOF Fix #52866 --- src/libsyntax/ext/tt/macro_parser.rs | 11 +++++++++-- src/libsyntax/ext/tt/macro_rules.rs | 9 +++++++++ src/test/ui/directory_ownership/macro-expanded-mod.rs | 3 ++- .../ui/directory_ownership/macro-expanded-mod.stderr | 6 +++--- .../edition-keywords-2018-2015-parsing.stderr | 6 +++--- .../edition-keywords-2018-2018-parsing.stderr | 6 +++--- src/test/ui/macros/macro-at-most-once-rep-2018.stderr | 8 ++++---- .../ui/macros/macro-in-expression-context-2.stderr | 2 +- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index f31d80acbfa..26604c46be5 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -724,7 +724,14 @@ 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, + ); } } // Performance hack: eof_items may share matchers via Rc with other things that we want @@ -757,7 +764,7 @@ 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); } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 6bba891278a..b67c46fe6f4 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -53,6 +53,15 @@ impl<'a> ParserAnyMacro<'a> { let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| { if e.span.is_dummy() { // Get around lack of span in error (#30128) e.set_span(site_span); + } else if parser.token == token::Eof { // (#52866) + e.set_span(parser.sess.source_map().next_point(parser.span)); + } + if parser.token == token::Eof { + let msg = &e.message[0]; + e.message[0] = ( + msg.0.replace(", found ``", ", found the end of the macro arm"), + msg.1, + ); } e })); diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs index 8e631a64f7a..78356f981fc 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.rs +++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs @@ -12,6 +12,7 @@ macro_rules! mod_decl { ($i:ident) => { mod $i; } + //~^ ERROR Cannot declare a non-inline module inside a block } mod macro_expanded_mod_helper { @@ -19,5 +20,5 @@ mod macro_expanded_mod_helper { } fn main() { - mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block + mod_decl!(foo); } diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/directory_ownership/macro-expanded-mod.stderr index a9efcd883c1..f58e864a755 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr +++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr @@ -1,8 +1,8 @@ error: Cannot declare a non-inline module inside a block unless it has a path attribute - --> $DIR/macro-expanded-mod.rs:22:15 + --> $DIR/macro-expanded-mod.rs:14:28 | -LL | mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block - | ^^^ +LL | ($i:ident) => { mod $i; } + | ^ error: aborting due to previous error 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..bf7fc28c758 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -22,11 +22,11 @@ error: no rules expected the token `async` LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected the token `async` -error: expected one of `move`, `|`, or `||`, found `` - --> <::edition_kw_macro_2015::passes_ident macros>:1:22 +error: expected one of `move`, `|`, or `||`, found the end of the macro arm + --> <::edition_kw_macro_2015::passes_ident macros>:1:25 | LL | ( $ i : ident ) => ( $ i ) - | ^^^ expected one of `move`, `|`, or `||` here + | ^ 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..4ab29ba67a0 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -22,11 +22,11 @@ error: no rules expected the token `async` LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected the token `async` -error: expected one of `move`, `|`, or `||`, found `` - --> <::edition_kw_macro_2018::passes_ident macros>:1:22 +error: expected one of `move`, `|`, or `||`, found the end of the macro arm + --> <::edition_kw_macro_2018::passes_ident macros>:1:25 | LL | ( $ i : ident ) => ( $ i ) - | ^^^ expected one of `move`, `|`, or `||` here + | ^ error: aborting due to 5 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..19a9cf3a6f5 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 @@ -41,13 +41,13 @@ LL | barplus!(); //~ERROR unexpected end of macro invocation | ^^^^^^^^^^^ unexpected end of macro invocation 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 + | ^ unexpected end of macro invocation error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:42:15 @@ -77,13 +77,13 @@ LL | barstar!(); //~ERROR unexpected end of macro invocation | ^^^^^^^^^^^ unexpected end of macro invocation 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 + | ^ unexpected end of macro invocation error: no rules expected the token `?` --> $DIR/macro-at-most-once-rep-2018.rs:49:15 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..3a4c9c0cdec 100644 --- a/src/test/ui/macros/macro-in-expression-context-2.stderr +++ b/src/test/ui/macros/macro-in-expression-context-2.stderr @@ -1,4 +1,4 @@ -error: expected expression, found `` +error: expected expression, found the end of the macro arm --> $DIR/macro-in-expression-context-2.rs:5:16 | LL | _ => { empty!() } From 34bd86a3fd69a49177cce88b34e16fbfdf8e0304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 4 Nov 2018 13:50:10 -0800 Subject: [PATCH 2/7] Add label when replacing primary DUMMY_SP in macro expansion --- src/libsyntax/ext/tt/macro_rules.rs | 1 + src/test/ui/macros/macro-in-expression-context-2.stderr | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index b67c46fe6f4..04f145ce32f 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -53,6 +53,7 @@ impl<'a> ParserAnyMacro<'a> { let fragment = panictry!(parser.parse_ast_fragment(kind, true).map_err(|mut e| { if e.span.is_dummy() { // Get around lack of span in error (#30128) e.set_span(site_span); + e.span_label(site_span, "in this macro expansion"); } else if parser.token == token::Eof { // (#52866) e.set_span(parser.sess.source_map().next_point(parser.span)); } 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 3a4c9c0cdec..0d4f1e82663 100644 --- a/src/test/ui/macros/macro-in-expression-context-2.stderr +++ b/src/test/ui/macros/macro-in-expression-context-2.stderr @@ -2,7 +2,7 @@ error: expected expression, found the end of the macro arm --> $DIR/macro-in-expression-context-2.rs:5:16 | LL | _ => { empty!() } - | ^^^^^^^^ + | ^^^^^^^^ in this macro expansion error: aborting due to previous error From e5cd1edfa190442f4e3e0f53c0ac28f6cc9d15f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 4 Nov 2018 14:01:38 -0800 Subject: [PATCH 3/7] Reword incorrect macro invocation primary label --- src/libsyntax/ext/tt/macro_parser.rs | 13 +++++++---- src/libsyntax/ext/tt/macro_rules.rs | 15 +++++++++---- .../edition-keywords-2015-2015-parsing.stderr | 4 ++-- .../edition-keywords-2015-2018-parsing.stderr | 4 ++-- .../edition-keywords-2018-2015-parsing.stderr | 4 ++-- .../edition-keywords-2018-2018-parsing.stderr | 4 ++-- src/test/ui/empty/empty-comment.stderr | 2 +- src/test/ui/fail-simple.stderr | 2 +- src/test/ui/issues/issue-7970a.stderr | 2 +- src/test/ui/issues/issue-7970b.stderr | 2 +- ...-at-most-once-rep-2018-feature-gate.stderr | 6 ++--- .../macros/macro-at-most-once-rep-2018.stderr | 22 +++++++++---------- src/test/ui/macros/macro-non-lifetime.stderr | 2 +- src/test/ui/macros/missing-comma.stderr | 8 +++---- .../ui/macros/nonterminal-matching.stderr | 2 +- src/test/ui/macros/trace_faulty_macros.stderr | 2 +- .../parser/macro/macro-doc-comments-1.stderr | 2 +- .../parser/macro/macro-doc-comments-2.stderr | 2 +- src/test/ui/underscore-ident-matcher.stderr | 2 +- .../ui/vec/vec-macro-with-comma-only.stderr | 2 +- 20 files changed, 57 insertions(+), 45 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 26604c46be5..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 { 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] @@ -731,6 +731,7 @@ pub fn parse( sess.source_map().next_point(parser.span) }, token::Eof, + "missing tokens in macro arguments".to_string(), ); } } @@ -766,7 +767,11 @@ pub fn parse( // If there are no possible next positions AND we aren't waiting for the black-box parser, // 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 04f145ce32f..5ce50f187d0 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}; @@ -130,6 +131,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 { @@ -185,9 +187,10 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt, macro_ident: name }) } - 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[..]) @@ -198,7 +201,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"); @@ -278,9 +281,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/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 bf7fc28c758..ad5794c75d3 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -14,13 +14,13 @@ 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 the end of the macro arm --> <::edition_kw_macro_2015::passes_ident macros>:1:25 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 4ab29ba67a0..c86817d482b 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -14,13 +14,13 @@ 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 the end of the macro arm --> <::edition_kw_macro_2018::passes_ident macros>:1:25 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 19a9cf3a6f5..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,7 +38,7 @@ 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:15 @@ -47,7 +47,7 @@ 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,7 +74,7 @@ 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:15 @@ -83,7 +83,7 @@ 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-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 From 76449d86c0c0b85ff93912a450012f2ece16c3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 5 Nov 2018 12:25:31 -0800 Subject: [PATCH 4/7] Point at macro arm when it doesn't expand to an expression --- src/libsyntax/ext/tt/macro_rules.rs | 10 +++++++--- .../ui/macros/macro-in-expression-context-2.stderr | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5ce50f187d0..fa10d219ad6 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -45,16 +45,18 @@ 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>, 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 e.span.is_dummy() { // Get around lack of span in error (#30128) e.set_span(site_span); e.span_label(site_span, "in this macro expansion"); + e.span_label(arm_span, "in this macro arm"); } else if parser.token == token::Eof { // (#52866) e.set_span(parser.sess.source_map().next_point(parser.span)); } @@ -146,6 +148,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::>(); // rhs has holes ( `$id` and `$(...)` that need filled) @@ -184,7 +187,8 @@ 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, t) => if sp.lo() >= best_fail_spot.lo() { 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 0d4f1e82663..f2b67ab6138 100644 --- a/src/test/ui/macros/macro-in-expression-context-2.stderr +++ b/src/test/ui/macros/macro-in-expression-context-2.stderr @@ -1,6 +1,9 @@ error: expected expression, found the end of the macro arm --> $DIR/macro-in-expression-context-2.rs:5:16 | +LL | macro_rules! empty { () => () } + | -- in this macro arm +... LL | _ => { empty!() } | ^^^^^^^^ in this macro expansion From c45871ba02430c3af6453d5636f8ad0afb7eb35f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 5 Nov 2018 16:27:28 -0800 Subject: [PATCH 5/7] Keep label on moved spans and point at macro invocation on parse error --- src/librustc_errors/diagnostic.rs | 11 ++++++++++ src/libsyntax/ext/tt/macro_rules.rs | 20 +++++++++++-------- .../directory_ownership/macro-expanded-mod.rs | 2 +- .../macro-expanded-mod.stderr | 6 +++--- .../edition-keywords-2018-2015-parsing.stderr | 7 ++++++- .../edition-keywords-2018-2018-parsing.stderr | 7 ++++++- .../macro-in-expression-context-2.stderr | 2 +- 7 files changed, 40 insertions(+), 15 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_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index fa10d219ad6..9f3a80b1151 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -53,20 +53,24 @@ impl<'a> ParserAnyMacro<'a> { pub fn make(mut self: Box>, kind: AstFragmentKind) -> AstFragment { 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 e.span.is_dummy() { // Get around lack of span in error (#30128) - e.set_span(site_span); - e.span_label(site_span, "in this macro expansion"); - e.span_label(arm_span, "in this macro arm"); - } else if parser.token == token::Eof { // (#52866) - e.set_span(parser.sess.source_map().next_point(parser.span)); - } - if parser.token == token::Eof { + if parser.token == token::Eof && e.message().ends_with(", found ``") { + 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] = ( msg.0.replace(", found ``", ", found the end of the macro arm"), msg.1, ); } + if e.span.is_dummy() { // Get around lack of span in error (#30128) + 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 })); diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs index 78356f981fc..59ebc94f6de 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.rs +++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs @@ -12,7 +12,6 @@ macro_rules! mod_decl { ($i:ident) => { mod $i; } - //~^ ERROR Cannot declare a non-inline module inside a block } mod macro_expanded_mod_helper { @@ -21,4 +20,5 @@ mod macro_expanded_mod_helper { fn main() { 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 f58e864a755..43bf720083d 100644 --- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr +++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr @@ -1,8 +1,8 @@ error: Cannot declare a non-inline module inside a block unless it has a path attribute - --> $DIR/macro-expanded-mod.rs:14:28 + --> $DIR/macro-expanded-mod.rs:22:15 | -LL | ($i:ident) => { mod $i; } - | ^ +LL | mod_decl!(foo); + | ^^^ error: aborting due to previous error 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 ad5794c75d3..943183814f7 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -26,7 +26,12 @@ error: expected one of `move`, `|`, or `||`, found the end of the macro arm --> <::edition_kw_macro_2015::passes_ident macros>:1:25 | LL | ( $ i : ident ) => ( $ i ) - | ^ + | ^ 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 c86817d482b..e7379988892 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -26,7 +26,12 @@ error: expected one of `move`, `|`, or `||`, found the end of the macro arm --> <::edition_kw_macro_2018::passes_ident macros>:1:25 | LL | ( $ i : ident ) => ( $ i ) - | ^ + | ^ 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/macros/macro-in-expression-context-2.stderr b/src/test/ui/macros/macro-in-expression-context-2.stderr index f2b67ab6138..f6e6ecf112a 100644 --- a/src/test/ui/macros/macro-in-expression-context-2.stderr +++ b/src/test/ui/macros/macro-in-expression-context-2.stderr @@ -5,7 +5,7 @@ LL | macro_rules! empty { () => () } | -- in this macro arm ... LL | _ => { empty!() } - | ^^^^^^^^ in this macro expansion + | ^^^^^^^^ expected expression error: aborting due to previous error From 950a3edf27bf3bad702b0f10ce771ae8bf7f58dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 5 Nov 2018 16:32:58 -0800 Subject: [PATCH 6/7] Fix proc-macro test after internal API change --- .../run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); From d011313d843b3ddcf095db06907abffdd9cc5904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 23 Nov 2018 15:37:27 -0800 Subject: [PATCH 7/7] Reword EOF in macro arm message --- src/libsyntax/ext/tt/macro_rules.rs | 5 ++++- .../ui/editions/edition-keywords-2018-2015-parsing.stderr | 2 +- .../ui/editions/edition-keywords-2018-2018-parsing.stderr | 2 +- src/test/ui/macros/macro-in-expression-context-2.stderr | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 9f3a80b1151..e731be578cd 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -59,7 +59,10 @@ impl<'a> ParserAnyMacro<'a> { } let msg = &e.message[0]; e.message[0] = ( - msg.0.replace(", found ``", ", found the end of the macro arm"), + format!( + "macro expansion ends with an incomplete expression: {}", + msg.0.replace(", found ``", ""), + ), msg.1, ); } 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 943183814f7..d0edc368ad5 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -22,7 +22,7 @@ error: no rules expected the token `async` LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call -error: expected one of `move`, `|`, or `||`, found the end of the macro arm +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 ) 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 e7379988892..c4e1e0257c5 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -22,7 +22,7 @@ error: no rules expected the token `async` LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the token `async` | ^^^^^ no rules expected this token in macro call -error: expected one of `move`, `|`, or `||`, found the end of the macro arm +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 ) 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 f6e6ecf112a..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,4 +1,4 @@ -error: expected expression, found the end of the macro arm +error: macro expansion ends with an incomplete expression: expected expression --> $DIR/macro-in-expression-context-2.rs:5:16 | LL | macro_rules! empty { () => () }