about summary refs log tree commit diff
path: root/tests/ui/attributes/statement-attribute-validation.rs
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2023-10-23 16:34:33 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2023-10-24 08:21:52 +0000
commit712106b1229f48e71a6365f5e5bf171403105750 (patch)
tree40dbadb43b4f343cbaa42e6c55f3716defb5850e /tests/ui/attributes/statement-attribute-validation.rs
parent8501f1c7ba440c97833ea9dec03965b4d5ef2fd7 (diff)
downloadrust-712106b1229f48e71a6365f5e5bf171403105750.tar.gz
rust-712106b1229f48e71a6365f5e5bf171403105750.zip
Add regression test for #117058
Diffstat (limited to 'tests/ui/attributes/statement-attribute-validation.rs')
-rw-r--r--tests/ui/attributes/statement-attribute-validation.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/attributes/statement-attribute-validation.rs b/tests/ui/attributes/statement-attribute-validation.rs
new file mode 100644
index 00000000000..31407364acf
--- /dev/null
+++ b/tests/ui/attributes/statement-attribute-validation.rs
@@ -0,0 +1,39 @@
+// test for #117058 - check that attributes are validated on various kinds of statements.
+
+struct A;
+
+fn func() {}
+
+fn main() {
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    if true {
+    } else {
+    }
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    (1);
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    match 1 {
+        _ => {}
+    }
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    while false {}
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    {}
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    A {};
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    func();
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    A;
+    #[allow(two-words)]
+    //~^ ERROR expected one of `(`, `,`, `::`, or `=`, found `-`
+    loop {}
+}