diff options
| author | jedel1043 <jedel0124@gmail.com> | 2021-05-16 09:49:16 -0500 |
|---|---|---|
| committer | jedel1043 <jedel0124@gmail.com> | 2021-05-16 09:49:16 -0500 |
| commit | 059b68dd677808e14e560802d235ad40beeba71e (patch) | |
| tree | 6527e4bbf4bb32c98f5c566a427fd176542569f2 /src/test | |
| parent | 8cf990c9b5c59f25c806fad9f4466f9d6509bbea (diff) | |
| download | rust-059b68dd677808e14e560802d235ad40beeba71e.tar.gz rust-059b68dd677808e14e560802d235ad40beeba71e.zip | |
Implement Anonymous{Struct, Union} in the AST
Add unnamed_fields feature gate and gate unnamed fields on parsing
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-unnamed_fields.rs | 27 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr | 111 |
2 files changed, 138 insertions, 0 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-unnamed_fields.rs b/src/test/ui/feature-gates/feature-gate-unnamed_fields.rs new file mode 100644 index 00000000000..bd815dbcc92 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-unnamed_fields.rs @@ -0,0 +1,27 @@ +struct Foo { + foo: u8, + _: union { //~ ERROR unnamed fields are not yet fully implemented [E0658] + //~^ ERROR unnamed fields are not yet fully implemented [E0658] + //~| ERROR anonymous unions are unimplemented + bar: u8, + baz: u16 + } +} + +union Bar { + foobar: u8, + _: struct { //~ ERROR unnamed fields are not yet fully implemented [E0658] + //~^ ERROR unnamed fields are not yet fully implemented [E0658] + //~| ERROR anonymous structs are unimplemented + //~| ERROR unions may not contain fields that need dropping [E0740] + foobaz: u8, + barbaz: u16 + } +} + +struct S; +struct Baz { + _: S //~ ERROR unnamed fields are not yet fully implemented [E0658] +} + +fn main(){} diff --git a/src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr b/src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr new file mode 100644 index 00000000000..4f3ab85c987 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr @@ -0,0 +1,111 @@ +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:3:5 + | +LL | _: union { + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:3:8 + | +LL | _: union { + | ________^ +LL | | +LL | | +LL | | bar: u8, +LL | | baz: u16 +LL | | } + | |_____^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:13:5 + | +LL | _: struct { + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:13:8 + | +LL | _: struct { + | ________^ +LL | | +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error[E0658]: unnamed fields are not yet fully implemented + --> $DIR/feature-gate-unnamed_fields.rs:24:5 + | +LL | _: S + | ^ + | + = note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information + = help: add `#![feature(unnamed_fields)]` to the crate attributes to enable + +error: anonymous unions are unimplemented + --> $DIR/feature-gate-unnamed_fields.rs:3:8 + | +LL | _: union { + | ________^ +LL | | +LL | | +LL | | bar: u8, +LL | | baz: u16 +LL | | } + | |_____^ + +error: anonymous structs are unimplemented + --> $DIR/feature-gate-unnamed_fields.rs:13:8 + | +LL | _: struct { + | ________^ +LL | | +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + +error[E0740]: unions may not contain fields that need dropping + --> $DIR/feature-gate-unnamed_fields.rs:13:5 + | +LL | / _: struct { +LL | | +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + | +note: `std::mem::ManuallyDrop` can be used to wrap the type + --> $DIR/feature-gate-unnamed_fields.rs:13:5 + | +LL | / _: struct { +LL | | +LL | | +LL | | +LL | | foobaz: u8, +LL | | barbaz: u16 +LL | | } + | |_____^ + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0658, E0740. +For more information about an error, try `rustc --explain E0658`. |
