rust/tests/compile-fail/invalid_enum_discriminant.rs
2016-06-23 09:36:37 +02:00

15 lines
273 B
Rust

#[repr(C)]
pub enum Foo {
A, B, C, D
}
fn main() {
let f = unsafe { std::mem::transmute::<i32, Foo>(42) };
match f {
Foo::A => {}, //~ ERROR invalid enum discriminant value read
Foo::B => {},
Foo::C => {},
Foo::D => {},
}
}