From ee7593e0ac83a1b18e7489b852952cd21e2a6947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 24 May 2019 15:17:32 -0700 Subject: [PATCH] Revert changes that belong to separate PR --- src/libsyntax/config.rs | 13 +------------ src/libsyntax/ext/derive.rs | 7 ++----- src/libsyntax/parse/diagnostics.rs | 2 +- .../ui/malformed/malformed-derive-entry.rs | 2 +- .../malformed/malformed-derive-entry.stderr | 6 ++---- .../ui/malformed/malformed-special-attrs.rs | 6 +++--- .../malformed/malformed-special-attrs.stderr | 19 ++++++------------- 7 files changed, 16 insertions(+), 39 deletions(-) diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 5ccec05dda20b..c82936afa3d9f 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -94,17 +94,6 @@ impl<'a> StripUnconfigured<'a> { if !attr.check_name(sym::cfg_attr) { return vec![attr]; } - if attr.tokens.len() == 0 { - self.sess.span_diagnostic.struct_span_err(attr.span, "bad `cfg_attr` attribute") - .span_label(attr.span, "missing condition and attribute") - .note("`cfg_attr` must be of the form: \ - `#[cfg_attr(condition, attribute, other_attribute, ...)]`") - .note("for more information, visit \ - ") - .emit(); - return vec![]; - } let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| { parser.expect(&token::OpenDelim(token::Paren))?; @@ -128,7 +117,7 @@ impl<'a> StripUnconfigured<'a> { Ok(result) => result, Err(mut e) => { e.emit(); - return vec![]; + return Vec::new(); } }; diff --git a/src/libsyntax/ext/derive.rs b/src/libsyntax/ext/derive.rs index bbdda4932f117..6e789c4c7086b 100644 --- a/src/libsyntax/ext/derive.rs +++ b/src/libsyntax/ext/derive.rs @@ -17,11 +17,8 @@ pub fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec) -> return true; } if !attr.is_meta_item_list() { - cx.struct_span_err(attr.span, "bad `derive` attribute") - .span_label(attr.span, "missing traits to be derived") - .note("`derive` must be of the form: \ - `#[derive(Trait1, Trait2, ...)]`") - .emit(); + cx.span_err(attr.span, + "attribute must be of the form `#[derive(Trait1, Trait2, ...)]`"); return false; } diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index e93c0bdb8336a..810acc9cc923e 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -618,7 +618,7 @@ impl<'a> Parser<'a> { let (span, msg) = match (&self.token, self.subparser_name) { (&token::Token::Eof, Some(origin)) => { let sp = self.sess.source_map().next_point(self.span); - (sp, format!( "expected expression, found end of {}", origin)) + (sp, format!("expected expression, found end of {}", origin)) } _ => (self.span, format!( "expected expression, found {}", diff --git a/src/test/ui/malformed/malformed-derive-entry.rs b/src/test/ui/malformed/malformed-derive-entry.rs index 1a87cd2d11cb5..36cc58f7e268e 100644 --- a/src/test/ui/malformed/malformed-derive-entry.rs +++ b/src/test/ui/malformed/malformed-derive-entry.rs @@ -7,7 +7,7 @@ struct Test2; #[derive()] //~ WARNING empty trait list struct Test3; -#[derive] //~ ERROR bad `derive` attribute +#[derive] //~ ERROR attribute must be of the form `#[derive(Trait1, Trait2, ...)]` struct Test4; fn main() {} diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index aa1334d21a86a..0dc18f6811117 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -16,13 +16,11 @@ warning: empty trait list in `derive` LL | #[derive()] | ^^^^^^^^^^^ -error: bad `derive` attribute +error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]` --> $DIR/malformed-derive-entry.rs:10:1 | LL | #[derive] - | ^^^^^^^^^ missing traits to be derived - | - = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/malformed/malformed-special-attrs.rs b/src/test/ui/malformed/malformed-special-attrs.rs index 5f1c4795a89b0..4d00755aea09d 100644 --- a/src/test/ui/malformed/malformed-special-attrs.rs +++ b/src/test/ui/malformed/malformed-special-attrs.rs @@ -1,13 +1,13 @@ -#[cfg_attr] //~ ERROR bad `cfg_attr` attribute +#[cfg_attr] //~ ERROR expected `(`, found end of attribute struct S1; #[cfg_attr = ""] //~ ERROR expected `(`, found `=` struct S2; -#[derive] //~ ERROR bad `derive` attribute +#[derive] //~ ERROR attribute must be of the form struct S3; -#[derive = ""] //~ ERROR bad `derive` attribute +#[derive = ""] //~ ERROR attribute must be of the form struct S4; fn main() {} diff --git a/src/test/ui/malformed/malformed-special-attrs.stderr b/src/test/ui/malformed/malformed-special-attrs.stderr index ad8015bf385a5..a93f03589e383 100644 --- a/src/test/ui/malformed/malformed-special-attrs.stderr +++ b/src/test/ui/malformed/malformed-special-attrs.stderr @@ -1,11 +1,8 @@ -error: bad `cfg_attr` attribute +error: expected `(`, found end of attribute --> $DIR/malformed-special-attrs.rs:1:1 | LL | #[cfg_attr] - | ^^^^^^^^^^^ missing condition and attribute - | - = note: `cfg_attr` must be of the form: `#[cfg_attr(condition, attribute, other_attribute, ...)]` - = note: for more information, visit + | ^ expected `(` error: expected `(`, found `=` --> $DIR/malformed-special-attrs.rs:4:12 @@ -13,21 +10,17 @@ error: expected `(`, found `=` LL | #[cfg_attr = ""] | ^ expected `(` -error: bad `derive` attribute +error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]` --> $DIR/malformed-special-attrs.rs:7:1 | LL | #[derive] - | ^^^^^^^^^ missing traits to be derived - | - = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^ -error: bad `derive` attribute +error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]` --> $DIR/malformed-special-attrs.rs:10:1 | LL | #[derive = ""] - | ^^^^^^^^^^^^^^ missing traits to be derived - | - = note: `derive` must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^^^^^^ error: aborting due to 4 previous errors