Skip to content

Commit

Permalink
Add a passing test for const unsafe_unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
canova committed Jul 17, 2020
1 parent 4fefa2c commit 2f28d59
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/ui/consts/const_unsafe_unreachable.rs
@@ -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);
}

0 comments on commit 2f28d59

Please sign in to comment.