summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const_unsafe_unreachable_ub.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const_unsafe_unreachable_ub.rs')
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable_ub.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.rs b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
new file mode 100644
index 000000000..b418fea61
--- /dev/null
+++ b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
@@ -0,0 +1,14 @@
+// error-pattern: evaluation of constant value failed
+
+const unsafe fn foo(x: bool) -> bool {
+ match x {
+ true => true,
+ false => std::hint::unreachable_unchecked(),
+ }
+}
+
+const BAR: bool = unsafe { foo(false) };
+
+fn main() {
+ assert_eq!(BAR, true);
+}