Files
rust/tests/ui/mir/enum/negative_discr_break.rs
Bastian Kersting 8a0d8dde44 Make the enum check work for negative discriminants
The discriminant check was not working correctly for negative numbers.
This change fixes that by masking out the relevant bits correctly.
2025-07-02 20:02:27 +03:00

15 lines
277 B
Rust

//@ run-fail
//@ compile-flags: -C debug-assertions
//@ error-pattern: trying to construct an enum from an invalid value 0xfd
#[allow(dead_code)]
enum Foo {
A = -2,
B = -1,
C = 1,
}
fn main() {
let _val: Foo = unsafe { std::mem::transmute::<i8, Foo>(-3) };
}