diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/repr/repr-transparent.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/tests/ui/repr/repr-transparent.rs b/tests/ui/repr/repr-transparent.rs index 8c9d1639c..87cf59ce9 100644 --- a/tests/ui/repr/repr-transparent.rs +++ b/tests/ui/repr/repr-transparent.rs @@ -23,23 +23,26 @@ struct ContainsMultipleZst(PhantomData<*const i32>, NoFields); struct ContainsZstAndNonZst((), [i32; 2]); #[repr(transparent)] -struct MultipleNonZst(u8, u8); //~ ERROR needs at most one non-zero-sized field +struct MultipleNonZst(u8, u8); //~ ERROR needs at most one field with non-trivial size or alignment trait Mirror { type It: ?Sized; } impl<T: ?Sized> Mirror for T { type It = Self; } #[repr(transparent)] pub struct StructWithProjection(f32, <f32 as Mirror>::It); -//~^ ERROR needs at most one non-zero-sized field +//~^ ERROR needs at most one field with non-trivial size or alignment #[repr(transparent)] -struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR alignment larger than 1 +struct NontrivialAlignZst(u32, [u16; 0]); //~ ERROR needs at most one field with non-trivial size or alignment #[repr(align(32))] struct ZstAlign32<T>(PhantomData<T>); #[repr(transparent)] -struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR alignment larger than 1 +struct GenericAlign<T>(ZstAlign32<T>, u32); //~ ERROR needs at most one field with non-trivial size or alignment + +#[repr(transparent)] +struct WrapsZstWithAlignment([i32; 0]); #[repr(transparent)] //~ ERROR unsupported representation for zero-variant enum enum Void {} //~ ERROR transparent enum needs exactly one variant, but has 0 @@ -58,7 +61,7 @@ enum UnitFieldEnum { enum TooManyFieldsEnum { Foo(u32, String), } -//~^^^ ERROR transparent enum needs at most one non-zero-sized field, but has 2 +//~^^^ ERROR transparent enum needs at most one field with non-trivial size or alignment, but has 2 #[repr(transparent)] enum MultipleVariants { //~ ERROR transparent enum needs exactly one variant, but has 2 @@ -67,13 +70,13 @@ enum MultipleVariants { //~ ERROR transparent enum needs exactly one variant, bu } #[repr(transparent)] -enum NontrivialAlignZstEnum { - Foo(u32, [u16; 0]), //~ ERROR alignment larger than 1 +enum NontrivialAlignZstEnum { //~ ERROR needs at most one field with non-trivial size or alignment + Foo(u32, [u16; 0]), } #[repr(transparent)] -enum GenericAlignEnum<T> { - Foo { bar: ZstAlign32<T>, baz: u32 } //~ ERROR alignment larger than 1 +enum GenericAlignEnum<T> { //~ ERROR needs at most one field with non-trivial size or alignment + Foo { bar: ZstAlign32<T>, baz: u32 } } #[repr(transparent)] @@ -82,7 +85,7 @@ union UnitUnion { } #[repr(transparent)] -union TooManyFields { //~ ERROR transparent union needs at most one non-zero-sized field, but has 2 +union TooManyFields { //~ ERROR transparent union needs at most one field with non-trivial size or alignment, but has 2 u: u32, s: i32 } |