diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-01-12 16:05:18 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-01-20 11:18:05 +0100 |
| commit | 25460ebef6ae94494fc89a736a2f51bef2ea55c3 (patch) | |
| tree | 7677f29a90f8372c2a0125e4fb3a3cb9f8bf3fce /src | |
| parent | 93efe41b4ef9e0cccedbf962381002d48b3f780c (diff) | |
| download | rust-25460ebef6ae94494fc89a736a2f51bef2ea55c3.tar.gz rust-25460ebef6ae94494fc89a736a2f51bef2ea55c3.zip | |
transparent_enums: test alignment
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/repr/repr-transparent.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/repr/repr-transparent.stderr | 18 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/test/ui/repr/repr-transparent.rs b/src/test/ui/repr/repr-transparent.rs index 969a323238f..8fbdb4cc80b 100644 --- a/src/test/ui/repr/repr-transparent.rs +++ b/src/test/ui/repr/repr-transparent.rs @@ -61,6 +61,16 @@ enum TooManyVariants { //~ ERROR transparent enum needs exactly one variant, but } #[repr(transparent)] +enum NontrivialAlignZstEnum { + Foo(u32, [u16; 0]), //~ ERROR alignment larger than 1 +} + +#[repr(transparent)] +enum GenericAlignEnum<T> { + Foo { bar: ZstAlign32<T>, baz: u32 } //~ ERROR alignment larger than 1 +} + +#[repr(transparent)] union UnitUnion { //~ ERROR transparent union needs exactly one non-zero-sized field, but has 0 u: (), } diff --git a/src/test/ui/repr/repr-transparent.stderr b/src/test/ui/repr/repr-transparent.stderr index f0c1fbe8ac9..cbc74fbb6a2 100644 --- a/src/test/ui/repr/repr-transparent.stderr +++ b/src/test/ui/repr/repr-transparent.stderr @@ -94,14 +94,26 @@ LL | Foo(String), LL | Bar, | --- too many variants in `TooManyVariants` +error[E0691]: zero-sized field in transparent enum has alignment larger than 1 + --> $DIR/repr-transparent.rs:65:14 + | +LL | Foo(u32, [u16; 0]), + | ^^^^^^^^ has alignment larger than 1 + +error[E0691]: zero-sized field in transparent enum has alignment larger than 1 + --> $DIR/repr-transparent.rs:70:11 + | +LL | Foo { bar: ZstAlign32<T>, baz: u32 } + | ^^^^^^^^^^^^^^^^^^ has alignment larger than 1 + error[E0690]: transparent union needs exactly one non-zero-sized field, but has 0 - --> $DIR/repr-transparent.rs:64:1 + --> $DIR/repr-transparent.rs:74:1 | LL | union UnitUnion { | ^^^^^^^^^^^^^^^ needs exactly one non-zero-sized field, but has 0 error[E0690]: transparent union needs exactly one non-zero-sized field, but has 2 - --> $DIR/repr-transparent.rs:69:1 + --> $DIR/repr-transparent.rs:79:1 | LL | union TooManyFields { | ^^^^^^^^^^^^^^^^^^^ needs exactly one non-zero-sized field, but has 2 @@ -110,7 +122,7 @@ LL | u: u32, LL | s: i32 | ------ this field is non-zero-sized -error: aborting due to 15 previous errors +error: aborting due to 17 previous errors Some errors have detailed explanations: E0084, E0690, E0691, E0731. For more information about an error, try `rustc --explain E0084`. |
