From 4a6aa363ccc41e92f8a6c395031c1745f063e464 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 21 Dec 2018 02:58:55 +0300 Subject: [PATCH] Address review comments and CI failures --- src/librustc_resolve/macros.rs | 2 +- src/libsyntax/parse/parser.rs | 1 + src/test/ui/issues/issue-6596-1.rs | 1 - src/test/ui/issues/issue-6596-1.stderr | 12 +---------- src/test/ui/issues/issue-6596-2.rs | 1 - src/test/ui/issues/issue-6596-2.stderr | 11 +--------- .../macros/macro-comma-behavior.core.stderr | 18 ++++++++--------- src/test/ui/macros/macro-comma-behavior.rs | 2 ++ .../ui/macros/macro-comma-behavior.std.stderr | 20 +++++++++---------- 9 files changed, 24 insertions(+), 44 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 1bdcf4577fef1..64a5f1e3b6fb4 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -196,7 +196,7 @@ impl<'a> base::Resolver for Resolver<'a> { Ok((def, ext)) => (def, ext), Err(Determinacy::Determined) if kind == MacroKind::Attr => { // Replace unresolved attributes with used inert attributes for better recovery. - return Ok(Some(self.get_macro(Def::NonMacroAttr(NonMacroAttrKind::Tool)))); + return Ok(Some(Lrc::new(SyntaxExtension::NonMacroAttr { mark_used: true }))); } Err(determinacy) => return Err(determinacy), }; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4e994dd67c882..99014964aa52c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2881,6 +2881,7 @@ impl<'a> Parser<'a> { let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); err.span_label(self.span, "unknown macro variable"); err.emit(); + self.bump(); return } token::Interpolated(ref nt) => { diff --git a/src/test/ui/issues/issue-6596-1.rs b/src/test/ui/issues/issue-6596-1.rs index 457f129f2d505..ce8a3a80e1f84 100644 --- a/src/test/ui/issues/issue-6596-1.rs +++ b/src/test/ui/issues/issue-6596-1.rs @@ -13,7 +13,6 @@ macro_rules! e { ($inp:ident) => ( $nonexistent //~^ ERROR unknown macro variable `nonexistent` - //~| ERROR cannot find value `nonexistent` in this scope ); } diff --git a/src/test/ui/issues/issue-6596-1.stderr b/src/test/ui/issues/issue-6596-1.stderr index 2a682348386f9..b7055ab19d0c5 100644 --- a/src/test/ui/issues/issue-6596-1.stderr +++ b/src/test/ui/issues/issue-6596-1.stderr @@ -7,15 +7,5 @@ LL | $nonexistent LL | e!(foo); | -------- in this macro invocation -error[E0425]: cannot find value `nonexistent` in this scope - --> $DIR/issue-6596-1.rs:14:9 - | -LL | $nonexistent - | ^^^^^^^^^^^^ not found in this scope -... -LL | e!(foo); - | -------- in this macro invocation - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/issues/issue-6596-2.rs b/src/test/ui/issues/issue-6596-2.rs index 9e8d937e8ab6f..5eaa187756eda 100644 --- a/src/test/ui/issues/issue-6596-2.rs +++ b/src/test/ui/issues/issue-6596-2.rs @@ -14,7 +14,6 @@ macro_rules! g { ($inp:ident) => ( { $inp $nonexistent } //~^ ERROR unknown macro variable `nonexistent` - //~| ERROR expected one of ); } diff --git a/src/test/ui/issues/issue-6596-2.stderr b/src/test/ui/issues/issue-6596-2.stderr index f2ed17f35e697..273654f2ae224 100644 --- a/src/test/ui/issues/issue-6596-2.stderr +++ b/src/test/ui/issues/issue-6596-2.stderr @@ -7,14 +7,5 @@ LL | { $inp $nonexistent } LL | g!(foo); | -------- in this macro invocation -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `nonexistent` - --> $DIR/issue-6596-2.rs:15:16 - | -LL | { $inp $nonexistent } - | ^^^^^^^^^^^^ expected one of 8 possible tokens here -... -LL | g!(foo); - | -------- in this macro invocation - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/macros/macro-comma-behavior.core.stderr b/src/test/ui/macros/macro-comma-behavior.core.stderr index fccada76d15e4..b7c8c6f394504 100644 --- a/src/test/ui/macros/macro-comma-behavior.core.stderr +++ b/src/test/ui/macros/macro-comma-behavior.core.stderr @@ -1,41 +1,41 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:27:23 + --> $DIR/macro-comma-behavior.rs:29:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:30:23 + --> $DIR/macro-comma-behavior.rs:32:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:36:29 + --> $DIR/macro-comma-behavior.rs:38:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:39:29 + --> $DIR/macro-comma-behavior.rs:41:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:60:19 + --> $DIR/macro-comma-behavior.rs:62:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:78:21 + --> $DIR/macro-comma-behavior.rs:80:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:87:24 + --> $DIR/macro-comma-behavior.rs:89:24 | LL | write!(f, "{}",)?; | ^^ @@ -44,7 +44,5 @@ error: `#[panic_handler]` function required, but not found error: language item required, but not found: `eh_personality` -error: language item required, but not found: `eh_unwind_resume` - -error: aborting due to 10 previous errors +error: aborting due to 9 previous errors diff --git a/src/test/ui/macros/macro-comma-behavior.rs b/src/test/ui/macros/macro-comma-behavior.rs index 620e57b463d1a..e130b4b349aaa 100644 --- a/src/test/ui/macros/macro-comma-behavior.rs +++ b/src/test/ui/macros/macro-comma-behavior.rs @@ -13,10 +13,12 @@ // compile-flags: -C debug_assertions=yes // revisions: std core +#![feature(lang_items)] #![cfg_attr(core, no_std)] #[cfg(std)] use std::fmt; #[cfg(core)] use core::fmt; +#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {} // (see documentation of the similarly-named test in run-pass) fn to_format_or_not_to_format() { diff --git a/src/test/ui/macros/macro-comma-behavior.std.stderr b/src/test/ui/macros/macro-comma-behavior.std.stderr index a87271ed026f9..6c508c6af03c4 100644 --- a/src/test/ui/macros/macro-comma-behavior.std.stderr +++ b/src/test/ui/macros/macro-comma-behavior.std.stderr @@ -1,59 +1,59 @@ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:27:23 + --> $DIR/macro-comma-behavior.rs:29:23 | LL | assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:30:23 + --> $DIR/macro-comma-behavior.rs:32:23 | LL | assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:36:29 + --> $DIR/macro-comma-behavior.rs:38:29 | LL | debug_assert_eq!(1, 1, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:39:29 + --> $DIR/macro-comma-behavior.rs:41:29 | LL | debug_assert_ne!(1, 2, "{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:44:18 + --> $DIR/macro-comma-behavior.rs:46:18 | LL | eprint!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:56:18 + --> $DIR/macro-comma-behavior.rs:58:18 | LL | format!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:60:19 + --> $DIR/macro-comma-behavior.rs:62:19 | LL | format_args!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:67:17 + --> $DIR/macro-comma-behavior.rs:69:17 | LL | print!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:78:21 + --> $DIR/macro-comma-behavior.rs:80:21 | LL | unimplemented!("{}",); | ^^ error: 1 positional argument in format string, but no arguments were given - --> $DIR/macro-comma-behavior.rs:87:24 + --> $DIR/macro-comma-behavior.rs:89:24 | LL | write!(f, "{}",)?; | ^^