summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser/underscore_item_not_const.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/underscore_item_not_const.rs')
-rw-r--r--tests/ui/parser/underscore_item_not_const.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/parser/underscore_item_not_const.rs b/tests/ui/parser/underscore_item_not_const.rs
new file mode 100644
index 000000000..c01ac4752
--- /dev/null
+++ b/tests/ui/parser/underscore_item_not_const.rs
@@ -0,0 +1,16 @@
+// Test that various non-const items do not syntactically permit `_` as a name.
+
+static _: () = (); //~ ERROR expected identifier, found reserved identifier `_`
+struct _(); //~ ERROR expected identifier, found reserved identifier `_`
+enum _ {} //~ ERROR expected identifier, found reserved identifier `_`
+fn _() {} //~ ERROR expected identifier, found reserved identifier `_`
+mod _ {} //~ ERROR expected identifier, found reserved identifier `_`
+type _ = (); //~ ERROR expected identifier, found reserved identifier `_`
+use _; //~ ERROR expected identifier, found reserved identifier `_`
+use _ as g; //~ ERROR expected identifier, found reserved identifier `_`
+trait _ {} //~ ERROR expected identifier, found reserved identifier `_`
+trait _ = Copy; //~ ERROR expected identifier, found reserved identifier `_`
+macro_rules! _ { () => {} } //~ ERROR expected identifier, found reserved identifier `_`
+union _ { f: u8 } //~ ERROR expected one of `!` or `::`, found reserved identifier `_`
+
+fn main() {}