Stabilize unreachable_unchecked as const fn · rust-lang/rust@11140ff (original) (raw)

6 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ use crate::intrinsics;
44 44 /// ```
45 45 #[inline]
46 46 #[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")]
48 48 pub const unsafe fn unreachable_unchecked() -> ! {
49 49 // SAFETY: the safety contract for `intrinsics::unreachable` must
50 50 // be upheld by the caller.
Original file line number Diff line number Diff line change
@@ -735,7 +735,7 @@ extern "rust-intrinsic" {
735 735 /// reach code marked with this function.
736 736 ///
737 737 /// 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")]
739 739 pub fn unreachable() -> !;
740 740
741 741 /// Informs the optimizer that a condition is always true.
Original file line number Diff line number Diff line change
@@ -103,7 +103,6 @@
103 103 #![feature(const_trait_impl)]
104 104 #![feature(const_type_id)]
105 105 #![feature(const_type_name)]
106 -#![feature(const_unreachable_unchecked)]
107 106 #![feature(const_default_impls)]
108 107 #![feature(duration_consts_2)]
109 108 #![feature(ptr_metadata)]
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
1 1 // run-pass
2 2
3 -#![feature(const_unreachable_unchecked)]
4 -
5 3 const unsafe fn foo(x: bool) -> bool {
6 4 match x {
7 5 true => true,
@@ -12,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
12 10 const BAR: bool = unsafe { foo(true) };
13 11
14 12 fn main() {
15 -assert_eq!(BAR, true);
13 + assert_eq!(BAR, true);
16 14 }
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
1 1 // error-pattern: evaluation of constant value failed
2 -#![feature(const_unreachable_unchecked)]
3 2
4 3 const unsafe fn foo(x: bool) -> bool {
5 4 match x {
@@ -11,5 +10,5 @@ const unsafe fn foo(x: bool) -> bool {
11 10 const BAR: bool = unsafe { foo(false) };
12 11
13 12 fn main() {
14 -assert_eq!(BAR, true);
13 + assert_eq!(BAR, true);
15 14 }
Original file line number Diff line number Diff line change
@@ -7,13 +7,13 @@ LL | unsafe { intrinsics::unreachable() }
7 7 | entering unreachable code
8 8 | inside `unreachable_unchecked` at $SRC_DIR/core/src/hint.rs:LL:COL
9 9 |
10 - ::: $DIR/const_unsafe_unreachable_ub.rs:7:18
10 + ::: $DIR/const_unsafe_unreachable_ub.rs:6:18
11 11 |
12 12 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
14 14 ...
15 15 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
17 17
18 18 error: aborting due to previous error
19 19