Layout error instead of an ICE for packed and aligned types

This commit is contained in:
Tomasz Miąsko 2021-03-20 00:00:00 +00:00
parent b9197978a9
commit d49f977ed9
3 changed files with 33 additions and 3 deletions

View file

@ -66,4 +66,15 @@ union Z {
i: i32,
}
#[repr(packed, align(0x100))]
pub struct S(u16); //~ ERROR type has conflicting packed and align representation hints
#[repr(packed, align(0x100))]
pub union U { //~ ERROR type has conflicting packed and align representation hints
u: u16
}
static B: U = U { u: 0 };
static A: S = S(0);
fn main() {}

View file

@ -74,7 +74,21 @@ LL | | i: i32,
LL | | }
| |_^
error: aborting due to 10 previous errors
error[E0587]: type has conflicting packed and align representation hints
--> $DIR/conflicting-repr-hints.rs:70:1
|
LL | pub struct S(u16);
| ^^^^^^^^^^^^^^^^^^
error[E0587]: type has conflicting packed and align representation hints
--> $DIR/conflicting-repr-hints.rs:73:1
|
LL | / pub union U {
LL | | u: u16
LL | | }
| |_^
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0566, E0587, E0634.
For more information about an error, try `rustc --explain E0566`.