about summary refs log tree commit diff
path: root/tests/ui/parser/attribute
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/attribute')
-rw-r--r--tests/ui/parser/attribute/attr-bad-meta-4.rs4
-rw-r--r--tests/ui/parser/attribute/attr-bad-meta-4.stderr10
-rw-r--r--tests/ui/parser/attribute/attr-incomplete.rs17
-rw-r--r--tests/ui/parser/attribute/attr-incomplete.stderr32
-rw-r--r--tests/ui/parser/attribute/attr-unquoted-ident.rs4
-rw-r--r--tests/ui/parser/attribute/attr-unquoted-ident.stderr4
6 files changed, 63 insertions, 8 deletions
diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.rs b/tests/ui/parser/attribute/attr-bad-meta-4.rs
index 937390a6da5..606b41e89a5 100644
--- a/tests/ui/parser/attribute/attr-bad-meta-4.rs
+++ b/tests/ui/parser/attribute/attr-bad-meta-4.rs
@@ -1,7 +1,7 @@
 macro_rules! mac {
     ($attr_item: meta) => {
         #[cfg($attr_item)]
-        //~^ ERROR expected unsuffixed literal, found `meta` metavariable
+        //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable
         struct S;
     }
 }
@@ -9,7 +9,7 @@ macro_rules! mac {
 mac!(an(arbitrary token stream));
 
 #[cfg(feature = -1)]
-//~^ ERROR expected unsuffixed literal, found `-`
+//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
 fn handler() {}
 
 fn main() {}
diff --git a/tests/ui/parser/attribute/attr-bad-meta-4.stderr b/tests/ui/parser/attribute/attr-bad-meta-4.stderr
index 9c6ab5adadf..1d939942fb9 100644
--- a/tests/ui/parser/attribute/attr-bad-meta-4.stderr
+++ b/tests/ui/parser/attribute/attr-bad-meta-4.stderr
@@ -1,10 +1,16 @@
-error: expected unsuffixed literal, found `-`
+error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `-`
   --> $DIR/attr-bad-meta-4.rs:11:17
    |
 LL | #[cfg(feature = -1)]
    |                 ^
+   |
+help: negative numbers are not literals, try removing the `-` sign
+   |
+LL - #[cfg(feature = -1)]
+LL + #[cfg(feature = 1)]
+   |
 
-error: expected unsuffixed literal, found `meta` metavariable
+error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `meta` metavariable
   --> $DIR/attr-bad-meta-4.rs:3:15
    |
 LL |         #[cfg($attr_item)]
diff --git a/tests/ui/parser/attribute/attr-incomplete.rs b/tests/ui/parser/attribute/attr-incomplete.rs
new file mode 100644
index 00000000000..49cb66e5f59
--- /dev/null
+++ b/tests/ui/parser/attribute/attr-incomplete.rs
@@ -0,0 +1,17 @@
+#[cfg(target-os = "windows")]
+//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+pub fn test1() { }
+
+#[cfg(target_os = %)]
+//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%`
+pub fn test2() { }
+
+#[cfg(target_os?)]
+//~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `?`
+pub fn test3() { }
+
+#[cfg[target_os]]
+//~^ ERROR wrong meta list delimiters
+pub fn test4() { }
+
+pub fn main() {}
diff --git a/tests/ui/parser/attribute/attr-incomplete.stderr b/tests/ui/parser/attribute/attr-incomplete.stderr
new file mode 100644
index 00000000000..5909820cef3
--- /dev/null
+++ b/tests/ui/parser/attribute/attr-incomplete.stderr
@@ -0,0 +1,32 @@
+error: expected one of `(`, `,`, `::`, or `=`, found `-`
+  --> $DIR/attr-incomplete.rs:1:13
+   |
+LL | #[cfg(target-os = "windows")]
+   |             ^ expected one of `(`, `,`, `::`, or `=`
+
+error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `%`
+  --> $DIR/attr-incomplete.rs:5:19
+   |
+LL | #[cfg(target_os = %)]
+   |                   ^
+
+error: expected one of `(`, `,`, `::`, or `=`, found `?`
+  --> $DIR/attr-incomplete.rs:9:16
+   |
+LL | #[cfg(target_os?)]
+   |                ^ expected one of `(`, `,`, `::`, or `=`
+
+error: wrong meta list delimiters
+  --> $DIR/attr-incomplete.rs:13:6
+   |
+LL | #[cfg[target_os]]
+   |      ^^^^^^^^^^^
+   |
+help: the delimiters should be `(` and `)`
+   |
+LL - #[cfg[target_os]]
+LL + #[cfg(target_os)]
+   |
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs
index 396265f715e..8a0c65b783a 100644
--- a/tests/ui/parser/attribute/attr-unquoted-ident.rs
+++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs
@@ -4,13 +4,13 @@
 
 fn main() {
     #[cfg(key=foo)]
-    //~^ ERROR expected unsuffixed literal, found `foo`
+    //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
     //~| HELP surround the identifier with quotation marks to make it into a string literal
     println!();
     #[cfg(key="bar")]
     println!();
     #[cfg(key=foo bar baz)]
-    //~^ ERROR expected unsuffixed literal, found `foo`
+    //~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
     //~| HELP surround the identifier with quotation marks to make it into a string literal
     println!();
 }
diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr
index 2d7997f1aea..8a2785280ad 100644
--- a/tests/ui/parser/attribute/attr-unquoted-ident.stderr
+++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr
@@ -1,4 +1,4 @@
-error: expected unsuffixed literal, found `foo`
+error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
   --> $DIR/attr-unquoted-ident.rs:6:15
    |
 LL |     #[cfg(key=foo)]
@@ -9,7 +9,7 @@ help: surround the identifier with quotation marks to make it into a string lite
 LL |     #[cfg(key="foo")]
    |               +   +
 
-error: expected unsuffixed literal, found `foo`
+error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `foo`
   --> $DIR/attr-unquoted-ident.rs:12:15
    |
 LL |     #[cfg(key=foo bar baz)]