about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-05-24 15:17:32 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-05-24 15:17:32 -0700
commitee7593e0ac83a1b18e7489b852952cd21e2a6947 (patch)
tree1cf1b4ebb2b880a99009c9d2428ac4e341136c52
parentda57ac38a669573ab693546775eb3ee5dc5b3fc4 (diff)
Revert changes that belong to separate PR
-rw-r--r--src/libsyntax/config.rs13
-rw-r--r--src/libsyntax/ext/derive.rs7
-rw-r--r--src/libsyntax/parse/diagnostics.rs2
-rw-r--r--src/test/ui/malformed/malformed-derive-entry.rs2
-rw-r--r--src/test/ui/malformed/malformed-derive-entry.stderr6
-rw-r--r--src/test/ui/malformed/malformed-special-attrs.rs6
-rw-r--r--src/test/ui/malformed/malformed-special-attrs.stderr19
7 files changed, 16 insertions, 39 deletions
diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs
index 5ccec05dda2..c82936afa3d 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 \
-                       <https://doc.rust-lang.org/reference/conditional-compilation.html\
-                       #the-cfg_attr-attribute>")
-                .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 bbdda4932f1..6e789c4c708 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<ast::Attribute>) ->
             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 e93c0bdb833..810acc9cc92 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 1a87cd2d11c..36cc58f7e26 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 aa1334d21a8..0dc18f68111 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 5f1c4795a89..4d00755aea0 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 ad8015bf385..a93f03589e3 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 <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
+   | ^ 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