rust/src/test/ui/consts/const_unsafe_unreachable.rs
2020-07-17 22:00:06 +02:00

18 lines
294 B
Rust

// run-pass
#![feature(const_fn)]
#![feature(const_unreachable_unchecked)]
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);
}