summaryrefslogtreecommitdiffstats
path: root/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs')
-rw-r--r--tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs
new file mode 100644
index 000000000..192bbba5a
--- /dev/null
+++ b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs
@@ -0,0 +1,37 @@
+#![allow(incomplete_features)]
+#![feature(unnamed_fields)]
+
+struct F {
+ field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
+ //~^ ERROR anonymous structs are unimplemented
+ _: struct { field: u8 },
+ //~^ ERROR anonymous structs are unimplemented
+}
+
+struct G {
+ _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types
+}
+
+union H {
+ field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
+ //~^ ERROR anonymous structs are unimplemented
+ _: struct { field: u8 },
+ //~^ ERROR anonymous structs are unimplemented
+}
+
+union I {
+ _: (u8, u8), //~ ERROR unnamed fields can only have struct or union types
+}
+
+enum K {
+ M {
+ _ : struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields
+ //~^ ERROR unnamed fields are not allowed outside of structs or unions
+ //~| ERROR anonymous structs are unimplemented
+ },
+ N {
+ _ : u8, //~ ERROR unnamed fields are not allowed outside of structs or unions
+ }
+}
+
+fn main() {}