about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNazım Can Altınova <canaltinova@gmail.com>2020-07-17 21:59:37 +0200
committerNazım Can Altınova <canaltinova@gmail.com>2020-07-17 22:00:06 +0200
commit2f28d5945dab495a77c67c6051eea116ce9ceee2 (patch)
tree178e890143d20755c775b7d4b7b58ee6d8c378f6
parent4fefa2c75d43dcf1184c7a7116cbd9595a8e49ab (diff)
downloadrust-2f28d5945dab495a77c67c6051eea116ce9ceee2.tar.gz
rust-2f28d5945dab495a77c67c6051eea116ce9ceee2.zip
Add a passing test for const unsafe_unreachable
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/consts/const_unsafe_unreachable.rs b/src/test/ui/consts/const_unsafe_unreachable.rs
new file mode 100644
index 00000000000..cfed6e5deb9
--- /dev/null
+++ b/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);
+}