Skip to content

Commit 0ded5a1

Browse files
authored
Rollup merge of rust-lang#89509 - jhpratt:stabilize-const_unreachable_unchecked, r=oli-obk
Stabilize `unreachable_unchecked` as `const fn` Closes rust-lang#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 rust-lang#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)
2 parents e8924bc + 23d227f commit 0ded5a1

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

core/src/hint.rs

Lines changed: 1 addition & 1 deletion
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.

core/src/intrinsics.rs

Lines changed: 1 addition & 1 deletion
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.

core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
#![feature(const_trait_impl)]
131131
#![feature(const_type_id)]
132132
#![feature(const_type_name)]
133-
#![feature(const_unreachable_unchecked)]
134133
#![feature(const_default_impls)]
135134
#![feature(duration_consts_2)]
136135
#![feature(ptr_metadata)]

0 commit comments

Comments
 (0)