rust/tests/compile-fail/match_char.rs
2018-08-30 15:57:17 +02:00

14 lines
540 B
Rust

//ignore-test FIXME: do some basic validation of invariants for all values in flight
//This does currently not get caught becuase it compiles to SwitchInt, which
//has no knowledge about data invariants.
fn main() {
assert!(std::char::from_u32(-1_i32 as u32).is_none());
let _ = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR constant evaluation error
//~^ NOTE tried to interpret an invalid 32-bit value as a char: 4294967295
'a' => {true},
'b' => {false},
_ => {true},
};
}