Skip to content

Commit 75e0985

Browse files
committed
Stabilize hint_assert_unchecked
Make both `hint_assert_unchecked` and `const_hint_assert_unchecked` stable as `hint_assert_unchecked`.
1 parent dc14f2c commit 75e0985

File tree

7 files changed

+7
-15
lines changed

7 files changed

+7
-15
lines changed

library/alloc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
#![feature(fmt_internals)]
127127
#![feature(fn_traits)]
128128
#![feature(hasher_prefixfree_extras)]
129-
#![feature(hint_assert_unchecked)]
129+
#![feature(inline_const)]
130130
#![feature(inplace_iteration)]
131131
#![feature(iter_advance_by)]
132132
#![feature(iter_next_chunk)]

library/core/src/hint.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ pub const unsafe fn unreachable_unchecked() -> ! {
146146
/// # Example
147147
///
148148
/// ```
149-
/// #![feature(hint_assert_unchecked)]
150-
///
151149
/// use core::hint;
152150
///
153151
/// /// # Safety
@@ -195,11 +193,11 @@ pub const unsafe fn unreachable_unchecked() -> ! {
195193
/// pointer already has the builtin assumption that it is nonnull. However, the optimizer can
196194
/// make use of this information even when it isn't as obvious, such as when checks happen in
197195
/// called functions.
196+
#[track_caller]
198197
#[inline(always)]
199198
#[doc(alias = "assume")]
200-
#[track_caller]
201-
#[unstable(feature = "hint_assert_unchecked", issue = "119131")]
202-
#[rustc_const_unstable(feature = "const_hint_assert_unchecked", issue = "119131")]
199+
#[stable(feature = "hint_assert_unchecked", since = "CURRENT_RUSTC_VERSION")]
200+
#[rustc_const_stable(feature = "hint_assert_unchecked", since = "CURRENT_RUSTC_VERSION")]
203201
pub const unsafe fn assert_unchecked(cond: bool) {
204202
// SAFETY: The caller promised `cond` is true.
205203
unsafe {

library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ extern "rust-intrinsic" {
959959
/// not be used if the invariant can be discovered by the optimizer on its
960960
/// own, or if it does not enable any significant optimizations.
961961
///
962-
/// This intrinsic does not have a stable counterpart.
962+
/// The stabilized version of this intrinsic is [`core::hint::assert_unchecked`].
963963
#[rustc_const_stable(feature = "const_assume", since = "1.77.0")]
964964
#[rustc_nounwind]
965965
#[unstable(feature = "core_intrinsics", issue = "none")]

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
#![feature(const_fmt_arguments_new)]
131131
#![feature(const_hash)]
132132
#![feature(const_heap)]
133-
#![feature(const_hint_assert_unchecked)]
134133
#![feature(const_index_range_slice_index)]
135134
#![feature(const_int_from_str)]
136135
#![feature(const_intrinsic_copy)]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
#![feature(fmt_internals)]
336336
#![feature(hasher_prefixfree_extras)]
337337
#![feature(hashmap_internals)]
338-
#![feature(hint_assert_unchecked)]
339338
#![feature(ip)]
340339
#![feature(maybe_uninit_slice)]
341340
#![feature(maybe_uninit_uninit_array)]
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
#![feature(hint_assert_unchecked)]
2-
#![feature(const_hint_assert_unchecked)]
3-
41
const _: () = unsafe {
52
let n = u32::MAX.count_ones();
63
std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed
74
};
85

9-
fn main() {
10-
}
6+
fn main() {}

tests/ui/consts/const-assert-unchecked-ub.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0080]: evaluation of constant value failed
2-
--> $DIR/const-assert-unchecked-ub.rs:6:5
2+
--> $DIR/const-assert-unchecked-ub.rs:3:5
33
|
44
LL | std::hint::assert_unchecked(n < 32);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false`

0 commit comments

Comments
 (0)