Add a passing test for const unsafe_unreachable
This commit is contained in:
parent
4fefa2c75d
commit
2f28d5945d
1 changed files with 17 additions and 0 deletions
17
src/test/ui/consts/const_unsafe_unreachable.rs
Normal file
17
src/test/ui/consts/const_unsafe_unreachable.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue