Skip to content

Commit 11140ff

Browse files
committed
Stabilize unreachable_unchecked as const fn
1 parent e737694 commit 11140ff

6 files changed

+7
-11
lines changed

library/core/src/hint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use crate::intrinsics;
4444
/// ```
4545
#[inline]
4646
#[stable(feature = "unreachable", since = "1.27.0")]
47-
#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")]
47+
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
4848
pub const unsafe fn unreachable_unchecked() -> ! {
4949
// SAFETY: the safety contract for `intrinsics::unreachable` must
5050
// be upheld by the caller.

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ extern "rust-intrinsic" {
735735
/// reach code marked with this function.
736736
///
737737
/// The stabilized version of this intrinsic is [`core::hint::unreachable_unchecked`].
738-
#[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")]
738+
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
739739
pub fn unreachable() -> !;
740740

741741
/// Informs the optimizer that a condition is always true.

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
#![feature(const_trait_impl)]
104104
#![feature(const_type_id)]
105105
#![feature(const_type_name)]
106-
#![feature(const_unreachable_unchecked)]
107106
#![feature(const_default_impls)]
108107
#![feature(duration_consts_2)]
109108
#![feature(ptr_metadata)]
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// run-pass
22

3-
#![feature(const_unreachable_unchecked)]
4-
53
const unsafe fn foo(x: bool) -> bool {
64
match x {
75
true => true,
@@ -12,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
1210
const BAR: bool = unsafe { foo(true) };
1311

1412
fn main() {
15-
assert_eq!(BAR, true);
13+
assert_eq!(BAR, true);
1614
}

src/test/ui/consts/const_unsafe_unreachable_ub.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// error-pattern: evaluation of constant value failed
2-
#![feature(const_unreachable_unchecked)]
32

43
const unsafe fn foo(x: bool) -> bool {
54
match x {
@@ -11,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
1110
const BAR: bool = unsafe { foo(false) };
1211

1312
fn main() {
14-
assert_eq!(BAR, true);
13+
assert_eq!(BAR, true);
1514
}

src/test/ui/consts/const_unsafe_unreachable_ub.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ LL | unsafe { intrinsics::unreachable() }
77
| entering unreachable code
88
| inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
99
|
10-
::: $DIR/const_unsafe_unreachable_ub.rs:7:18
10+
::: $DIR/const_unsafe_unreachable_ub.rs:6:18
1111
|
1212
LL | false => std::hint::unreachable_unchecked(),
13-
| ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:7:18
13+
| ---------------------------------- inside `foo` at $DIR/const_unsafe_unreachable_ub.rs:6:18
1414
...
1515
LL | const BAR: bool = unsafe { foo(false) };
16-
| ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:11:28
16+
| ---------- inside `BAR` at $DIR/const_unsafe_unreachable_ub.rs:10:28
1717

1818
error: aborting due to previous error
1919

0 commit comments

Comments
 (0)