diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2024-02-22 17:22:40 +0000 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2024-02-23 12:25:23 +0000 |
| commit | 35a9e7352138b059eaae2a9d0724dcd7f6d10ab5 (patch) | |
| tree | 21dd696d3cf7414937981972a9300b9a2cd9681e /tests/ui | |
| parent | 1bb3a9f67a2ff6bd49c513ca1b8954237298c4b3 (diff) | |
| download | rust-35a9e7352138b059eaae2a9d0724dcd7f6d10ab5.tar.gz rust-35a9e7352138b059eaae2a9d0724dcd7f6d10ab5.zip | |
Don't ICE on anonymous struct in enum variant
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs | 11 | ||||
| -rw-r--r-- | tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs new file mode 100644 index 00000000000..00f9bfd5cdf --- /dev/null +++ b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs @@ -0,0 +1,11 @@ +#![crate_type = "lib"] +#![feature(unnamed_fields)] +#![allow(unused, incomplete_features)] + +enum K { + M { + _ : struct { field: u8 }, + //~^ error: unnamed fields are not allowed outside of structs or unions + //~| error: anonymous structs are not allowed outside of unnamed struct or union fields + } +} diff --git a/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr new file mode 100644 index 00000000000..43843141e2e --- /dev/null +++ b/tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.stderr @@ -0,0 +1,16 @@ +error: unnamed fields are not allowed outside of structs or unions + --> $DIR/anon-struct-in-enum-issue-121446.rs:7:9 + | +LL | _ : struct { field: u8 }, + | -^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unnamed field declared here + +error: anonymous structs are not allowed outside of unnamed struct or union fields + --> $DIR/anon-struct-in-enum-issue-121446.rs:7:13 + | +LL | _ : struct { field: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here + +error: aborting due to 2 previous errors + |
