]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/const_unsafe_unreachable_ub.rs
Rollup merge of #106962 - compiler-errors:use-sugg-span, r=oli-obk
[rust.git] / tests / ui / consts / const_unsafe_unreachable_ub.rs
1 // error-pattern: evaluation of constant value failed
2
3 const unsafe fn foo(x: bool) -> bool {
4     match x {
5         true => true,
6         false => std::hint::unreachable_unchecked(),
7     }
8 }
9
10 const BAR: bool = unsafe { foo(false) };
11
12 fn main() {
13     assert_eq!(BAR, true);
14 }