about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-16 08:02:20 +0200
committerGitHub <noreply@github.com>2021-10-16 08:02:20 +0200
commit9ae0804859614ff2e76b26f551ef2cdb19e927ef (patch)
tree2a9b516c1279697e01c193ff4367850dd16132da /src
parent6cc0a764e082d9c0abcf37a768d5889247ba13e2 (diff)
parent11140ff1a0dd3a395dd3ca1488bf580559f782f8 (diff)
downloadrust-9ae0804859614ff2e76b26f551ef2cdb19e927ef.tar.gz
rust-9ae0804859614ff2e76b26f551ef2cdb19e927ef.zip
Rollup merge of #89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk
Stabilize `unreachable_unchecked` as `const fn`

Closes #53188

This PR stabilizes `core::hint::unreachable_unchecked` as `const fn`. MIRI is able to detect when this method is called. Stabilization was delayed until `const_panic` was stabilized so as to avoid users calling this method in its place (thus resulting in runtime UB). With #89508, that is no longer an issue.

````@rustbot```` label +A-const-eval +A-const-fn +T-lang +S-blocked

(not sure why it's T-lang, but that's what the tracking issue is)
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable.rs4
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable_ub.rs3
-rw-r--r--src/test/ui/consts/const_unsafe_unreachable_ub.stderr6
3 files changed, 5 insertions, 8 deletions
diff --git a/src/test/ui/consts/const_unsafe_unreachable.rs b/src/test/ui/consts/const_unsafe_unreachable.rs
index 1fec491ca95..1c3baec5d86 100644
--- a/src/test/ui/consts/const_unsafe_unreachable.rs
+++ b/src/test/ui/consts/const_unsafe_unreachable.rs
@@ -1,7 +1,5 @@
 // run-pass
 
-#![feature(const_unreachable_unchecked)]
-
 const unsafe fn foo(x: bool) -> bool {
     match x {
         true => true,
@@ -12,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
 const BAR: bool = unsafe { foo(true) };
 
 fn main() {
-  assert_eq!(BAR, true);
+    assert_eq!(BAR, true);
 }
diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.rs b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
index 8cee5b50651..b418fea617c 100644
--- a/src/test/ui/consts/const_unsafe_unreachable_ub.rs
+++ b/src/test/ui/consts/const_unsafe_unreachable_ub.rs
@@ -1,5 +1,4 @@
 // error-pattern: evaluation of constant value failed
-#![feature(const_unreachable_unchecked)]
 
 const unsafe fn foo(x: bool) -> bool {
     match x {
@@ -11,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
 const BAR: bool = unsafe { foo(false) };
 
 fn main() {
-  assert_eq!(BAR, true);
+    assert_eq!(BAR, true);
 }
diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
index 65cb3d74b23..ec6ce1f5d7c 100644
--- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
+++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr
@@ -7,13 +7,13 @@ LL |     unsafe { intrinsics::unreachable() }
    |              entering unreachable code
    |              inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
    |
-  ::: $DIR/const_unsafe_unreachable_ub.rs:7:18
+  ::: $DIR/const_unsafe_unreachable_ub.rs:6:18
    |
 LL |         false => std::hint::unreachable_unchecked(),
-   |                  ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
+   |                  ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:6:18
 ...
 LL | const BAR: bool = unsafe { foo(false) };
-   |                            ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
+   |                            ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:10:28
 
 error: aborting due to previous error