rust/tests/ui/lint/ice-const-prop-unions-known-panics-lint-123710.rs
Gurinder Singh 254a9fbe86 Prohibit const prop of unions in KnownPanicsLint
as they have a potential to ICE during layout calculation
2024-04-29 08:16:26 +05:30

23 lines
528 B
Rust

// Regression test for issue 123710.
// Tests that the we do not ICE in KnownPanicsLint
// when a union contains an enum with an repr(packed),
// which is a repr not supported for enums
#[repr(packed)]
//~^ ERROR attribute should be applied to a struct or union
#[repr(u32)]
enum E {
A,
B,
C,
}
fn main() {
union InvalidTag {
int: u32,
e: E,
//~^ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
}
let _invalid_tag = InvalidTag { int: 4 };
}