diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2021-10-04 01:04:17 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2021-10-04 01:04:17 -0400 |
| commit | 11140ff1a0dd3a395dd3ca1488bf580559f782f8 (patch) | |
| tree | c34d70739b014c1b33b71e0a59ceddaafdfc64ce | |
| parent | e737694a4d66b01308b73d4559a35b43e414faf9 (diff) | |
| download | rust-11140ff1a0dd3a395dd3ca1488bf580559f782f8.tar.gz rust-11140ff1a0dd3a395dd3ca1488bf580559f782f8.zip | |
Stabilize `unreachable_unchecked` as `const fn`
| -rw-r--r-- | library/core/src/hint.rs | 2 | ||||
| -rw-r--r-- | library/core/src/intrinsics.rs | 2 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/consts/const_unsafe_unreachable.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/consts/const_unsafe_unreachable_ub.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/consts/const_unsafe_unreachable_ub.stderr | 6 |
6 files changed, 7 insertions, 11 deletions
diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 1c3afcdaa69..95798879155 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -44,7 +44,7 @@ use crate::intrinsics; /// ``` #[inline] #[stable(feature = "unreachable", since = "1.27.0")] -#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] +#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] pub const unsafe fn unreachable_unchecked() -> ! { // SAFETY: the safety contract for `intrinsics::unreachable` must // be upheld by the caller. diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 3e26d46ddca..067a27fed41 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -735,7 +735,7 @@ extern "rust-intrinsic" { /// reach code marked with this function. /// /// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`]. - #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")] + #[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")] pub fn unreachable() -> !; /// Informs the optimizer that a condition is always true. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2230461b5f4..9a966cc5128 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -103,7 +103,6 @@ #![feature(const_trait_impl)] #![feature(const_type_id)] #![feature(const_type_name)] -#![feature(const_unreachable_unchecked)] #![feature(const_default_impls)] #![feature(duration_consts_2)] #![feature(ptr_metadata)] 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 |
