rust/tests/ui/consts/const_unsafe_unreachable.rs

15 lines
232 B
Rust
Raw Normal View History

// run-pass
const unsafe fn foo(x: bool) -> bool {
match x {
true => true,
false => std::hint::unreachable_unchecked(),
}
}
const BAR: bool = unsafe { foo(true) };
fn main() {
assert_eq!(BAR, true);
}