Skip to content

Commit ee78601

Browse files
committed
stabilize const_ptr_is_null
1 parent 4010980 commit ee78601

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

core/src/intrinsics/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3292,8 +3292,8 @@ pub const unsafe fn ptr_offset_from_unsigned<T>(_ptr: *const T, _base: *const T)
32923292

32933293
/// See documentation of `<*const T>::guaranteed_eq` for details.
32943294
/// Returns `2` if the result is unknown.
3295-
/// Returns `1` if the pointers are guaranteed equal
3296-
/// Returns `0` if the pointers are guaranteed inequal
3295+
/// Returns `1` if the pointers are guaranteed equal.
3296+
/// Returns `0` if the pointers are guaranteed inequal.
32973297
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020"))]
32983298
#[rustc_intrinsic]
32993299
#[rustc_nounwind]

core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
#![feature(const_heap)]
122122
#![feature(const_nonnull_new)]
123123
#![feature(const_pin_2)]
124-
#![feature(const_ptr_is_null)]
125124
#![feature(const_ptr_sub_ptr)]
126125
#![feature(const_raw_ptr_comparison)]
127126
#![feature(const_size_of_val)]

core/src/ptr/const_ptr.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ impl<T: ?Sized> *const T {
2929
/// assert!(!ptr.is_null());
3030
/// ```
3131
#[stable(feature = "rust1", since = "1.0.0")]
32-
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
32+
#[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")]
3333
#[rustc_diagnostic_item = "ptr_const_is_null"]
3434
#[inline]
35+
#[rustc_allow_const_fn_unstable(const_eval_select)]
3536
pub const fn is_null(self) -> bool {
3637
// Compare via a cast to a thin pointer, so fat pointers are only
3738
// considering their "data" part for null-ness.
3839
let ptr = self as *const u8;
3940
const_eval_select!(
4041
@capture { ptr: *const u8 } -> bool:
41-
if const #[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")] {
42+
// This use of `const_raw_ptr_comparison` has been explicitly blessed by t-lang.
43+
if const #[rustc_allow_const_fn_unstable(const_raw_ptr_comparison)] {
4244
match (ptr).guaranteed_eq(null_mut()) {
4345
Some(res) => res,
4446
// To remain maximally convervative, we stop execution when we don't
@@ -280,7 +282,7 @@ impl<T: ?Sized> *const T {
280282
/// }
281283
/// ```
282284
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
283-
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
285+
#[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")]
284286
#[inline]
285287
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> {
286288
// SAFETY: the caller must guarantee that `self` is valid

core/src/ptr/mut_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<T: ?Sized> *mut T {
2929
/// assert!(!ptr.is_null());
3030
/// ```
3131
#[stable(feature = "rust1", since = "1.0.0")]
32-
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
32+
#[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")]
3333
#[rustc_diagnostic_item = "ptr_is_null"]
3434
#[inline]
3535
pub const fn is_null(self) -> bool {
@@ -271,7 +271,7 @@ impl<T: ?Sized> *mut T {
271271
/// }
272272
/// ```
273273
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
274-
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
274+
#[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")]
275275
#[inline]
276276
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> {
277277
// SAFETY: the caller must guarantee that `self` is valid for a
@@ -619,7 +619,7 @@ impl<T: ?Sized> *mut T {
619619
/// println!("{s:?}"); // It'll print: "[4, 2, 3]".
620620
/// ```
621621
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
622-
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
622+
#[rustc_const_stable(feature = "const_ptr_is_null", since = "CURRENT_RUSTC_VERSION")]
623623
#[inline]
624624
pub const unsafe fn as_mut<'a>(self) -> Option<&'a mut T> {
625625
// SAFETY: the caller must guarantee that `self` is be valid for

core/src/ub_checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ macro_rules! assert_unsafe_precondition {
6565
#[inline]
6666
#[rustc_nounwind]
6767
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_ub_checks", issue = "none"))]
68-
#[rustc_allow_const_fn_unstable(const_ptr_is_null, const_ub_checks)] // only for UB checks
68+
#[rustc_allow_const_fn_unstable(const_ub_checks)] // only for UB checks
6969
const fn precondition_check($($name:$ty),*) {
7070
if !$e {
7171
::core::panicking::panic_nounwind(

0 commit comments

Comments
 (0)