about summary refs log tree commit diff
path: root/tests/ui/conditional-compilation
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/conditional-compilation')
-rw-r--r--tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs25
-rw-r--r--tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr63
2 files changed, 58 insertions, 30 deletions
diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs
index 47418b4e091..df87a3d846e 100644
--- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs
+++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs
@@ -1,16 +1,24 @@
-#[cfg] //~ ERROR `cfg` is not followed by parentheses
+#[cfg]
+//~^ ERROR malformed `cfg` attribute
+//~| NOTE expected this to be a list
 struct S1;
 
-#[cfg = 10] //~ ERROR `cfg` is not followed by parentheses
+#[cfg = 10]
+//~^ ERROR malformed `cfg` attribute
+//~| NOTE expected this to be a list
 struct S2;
 
-#[cfg()] //~ ERROR `cfg` predicate is not specified
+#[cfg()]
+//~^ ERROR malformed `cfg` attribute
+//~| NOTE expected a single argument here
 struct S3;
 
-#[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified
+#[cfg(a, b)]
+//~^ ERROR malformed `cfg` attribute
+//~| NOTE expected a single argument here
 struct S4;
 
-#[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal
+#[cfg("str")] //~ ERROR `cfg` predicate key must be an identifier
 struct S5;
 
 #[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier
@@ -19,10 +27,12 @@ struct S6;
 #[cfg(a())] //~ ERROR invalid predicate `a`
 struct S7;
 
-#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
+#[cfg(a = 10)] //~ ERROR malformed `cfg` attribute input
+//~^ NOTE expected a string literal here
 struct S8;
 
-#[cfg(a = b"hi")]  //~ ERROR literal in `cfg` predicate value must be a string
+#[cfg(a = b"hi")]  //~ ERROR malformed `cfg` attribute input
+//~^ NOTE expected a normal string literal, not a byte string literal
 struct S9;
 
 macro_rules! generate_s10 {
@@ -34,5 +44,6 @@ macro_rules! generate_s10 {
 }
 
 generate_s10!(concat!("nonexistent"));
+//~^ NOTE in this expansion of generate_s10!
 
 fn main() {}
diff --git a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr
index 66ce2ee9858..75e9b9209c0 100644
--- a/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr
+++ b/tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr
@@ -1,61 +1,78 @@
-error: `cfg` is not followed by parentheses
+error[E0539]: malformed `cfg` attribute input
   --> $DIR/cfg-attr-syntax-validation.rs:1:1
    |
 LL | #[cfg]
-   | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
+   | ^^^^^^
+   | |
+   | expected this to be a list
+   | help: must be of the form: `#[cfg(predicate)]`
 
-error: `cfg` is not followed by parentheses
-  --> $DIR/cfg-attr-syntax-validation.rs:4:1
+error[E0539]: malformed `cfg` attribute input
+  --> $DIR/cfg-attr-syntax-validation.rs:6:1
    |
 LL | #[cfg = 10]
-   | ^^^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
+   | ^^^^^^^^^^^
+   | |
+   | expected this to be a list
+   | help: must be of the form: `#[cfg(predicate)]`
 
-error: `cfg` predicate is not specified
-  --> $DIR/cfg-attr-syntax-validation.rs:7:1
+error[E0805]: malformed `cfg` attribute input
+  --> $DIR/cfg-attr-syntax-validation.rs:11:1
    |
 LL | #[cfg()]
-   | ^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)`
+   | ^^^^^--^
+   | |    |
+   | |    expected a single argument here
+   | help: must be of the form: `#[cfg(predicate)]`
 
-error: multiple `cfg` predicates are specified
-  --> $DIR/cfg-attr-syntax-validation.rs:10:10
+error[E0805]: malformed `cfg` attribute input
+  --> $DIR/cfg-attr-syntax-validation.rs:16:1
    |
 LL | #[cfg(a, b)]
-   |          ^
+   | ^^^^^------^
+   | |    |
+   | |    expected a single argument here
+   | help: must be of the form: `#[cfg(predicate)]`
 
-error: `cfg` predicate key cannot be a literal
-  --> $DIR/cfg-attr-syntax-validation.rs:13:7
+error: `cfg` predicate key must be an identifier
+  --> $DIR/cfg-attr-syntax-validation.rs:21:7
    |
 LL | #[cfg("str")]
    |       ^^^^^
 
 error: `cfg` predicate key must be an identifier
-  --> $DIR/cfg-attr-syntax-validation.rs:16:7
+  --> $DIR/cfg-attr-syntax-validation.rs:24:7
    |
 LL | #[cfg(a::b)]
    |       ^^^^
 
 error[E0537]: invalid predicate `a`
-  --> $DIR/cfg-attr-syntax-validation.rs:19:7
+  --> $DIR/cfg-attr-syntax-validation.rs:27:7
    |
 LL | #[cfg(a())]
    |       ^^^
 
-error[E0565]: literal in `cfg` predicate value must be a string
-  --> $DIR/cfg-attr-syntax-validation.rs:22:11
+error[E0539]: malformed `cfg` attribute input
+  --> $DIR/cfg-attr-syntax-validation.rs:30:1
    |
 LL | #[cfg(a = 10)]
-   |           ^^
+   | ^^^^^^^^^^--^^
+   | |         |
+   | |         expected a string literal here
+   | help: must be of the form: `#[cfg(predicate)]`
 
-error[E0565]: literal in `cfg` predicate value must be a string
-  --> $DIR/cfg-attr-syntax-validation.rs:25:11
+error[E0539]: malformed `cfg` attribute input
+  --> $DIR/cfg-attr-syntax-validation.rs:34:1
    |
 LL | #[cfg(a = b"hi")]
-   |           -^^^^
+   | ^^^^^^^^^^-^^^^^^
    |           |
    |           help: consider removing the prefix
+   |
+   = note: expected a normal string literal, not a byte string literal
 
 error: expected unsuffixed literal, found `expr` metavariable
-  --> $DIR/cfg-attr-syntax-validation.rs:30:25
+  --> $DIR/cfg-attr-syntax-validation.rs:40:25
    |
 LL |         #[cfg(feature = $expr)]
    |                         ^^^^^
@@ -67,5 +84,5 @@ LL | generate_s10!(concat!("nonexistent"));
 
 error: aborting due to 10 previous errors
 
-Some errors have detailed explanations: E0537, E0565.
+Some errors have detailed explanations: E0537, E0539, E0805.
 For more information about an error, try `rustc --explain E0537`.