From fb9e1f73b36ee867b6ff14ab977afa5a57c8c025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Fri, 12 Apr 2024 21:23:20 +0200 Subject: [PATCH] Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull --- library/alloc/src/lib.rs | 1 - library/core/src/lib.rs | 1 - library/core/src/ptr/const_ptr.rs | 14 ++++++-------- library/core/src/ptr/mut_ptr.rs | 11 +++++------ library/core/src/ptr/non_null.rs | 9 +++++---- library/core/tests/lib.rs | 1 - library/std/src/lib.rs | 1 - tests/ui/consts/const_fn_unsize.rs | 1 - 8 files changed, 16 insertions(+), 23 deletions(-) diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index f638c5cf8c71c..dec04d7e421e3 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -151,7 +151,6 @@ #![feature(slice_from_ptr_range)] #![feature(slice_index_methods)] #![feature(slice_ptr_get)] -#![feature(slice_ptr_len)] #![feature(slice_range)] #![feature(std_internals)] #![feature(str_internals)] diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 10d2698c5dd1b..85312371cda6e 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -158,7 +158,6 @@ #![feature(const_slice_from_raw_parts_mut)] #![feature(const_slice_from_ref)] #![feature(const_slice_index)] -#![feature(const_slice_ptr_len)] #![feature(const_slice_split_at_mut)] #![feature(const_str_from_utf8_unchecked_mut)] #![feature(const_strict_overflow_ops)] diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs index 01db050e666f2..9737fb8816e9c 100644 --- a/library/core/src/ptr/const_ptr.rs +++ b/library/core/src/ptr/const_ptr.rs @@ -1647,16 +1647,15 @@ impl *const [T] { /// # Examples /// /// ```rust - /// #![feature(slice_ptr_len)] - /// /// use std::ptr; /// /// let slice: *const [i8] = ptr::slice_from_raw_parts(ptr::null(), 3); /// assert_eq!(slice.len(), 3); /// ``` #[inline] - #[unstable(feature = "slice_ptr_len", issue = "71146")] - #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")] + #[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_allow_const_fn_unstable(ptr_metadata)] pub const fn len(self) -> usize { metadata(self) } @@ -1666,15 +1665,14 @@ impl *const [T] { /// # Examples /// /// ``` - /// #![feature(slice_ptr_len)] /// use std::ptr; /// /// let slice: *const [i8] = ptr::slice_from_raw_parts(ptr::null(), 3); /// assert!(!slice.is_empty()); /// ``` #[inline(always)] - #[unstable(feature = "slice_ptr_len", issue = "71146")] - #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")] + #[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] pub const fn is_empty(self) -> bool { self.len() == 0 } @@ -1804,7 +1802,7 @@ impl *const [T; N] { /// # Examples /// /// ``` - /// #![feature(array_ptr_get, slice_ptr_len)] + /// #![feature(array_ptr_get)] /// /// let arr: *const [i32; 3] = &[1, 2, 4] as *const [i32; 3]; /// let slice: *const [i32] = arr.as_slice(); diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs index 41e5ba6745827..08f03af355da8 100644 --- a/library/core/src/ptr/mut_ptr.rs +++ b/library/core/src/ptr/mut_ptr.rs @@ -1909,15 +1909,15 @@ impl *mut [T] { /// # Examples /// /// ```rust - /// #![feature(slice_ptr_len)] /// use std::ptr; /// /// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3); /// assert_eq!(slice.len(), 3); /// ``` #[inline(always)] - #[unstable(feature = "slice_ptr_len", issue = "71146")] - #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")] + #[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_allow_const_fn_unstable(ptr_metadata)] pub const fn len(self) -> usize { metadata(self) } @@ -1927,15 +1927,14 @@ impl *mut [T] { /// # Examples /// /// ``` - /// #![feature(slice_ptr_len)] /// use std::ptr; /// /// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3); /// assert!(!slice.is_empty()); /// ``` #[inline(always)] - #[unstable(feature = "slice_ptr_len", issue = "71146")] - #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")] + #[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")] pub const fn is_empty(self) -> bool { self.len() == 0 } diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index f0e4b958bc603..96ce3cd3a3fb5 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -1562,7 +1562,6 @@ impl NonNull<[T]> { /// ``` #[stable(feature = "slice_ptr_len_nonnull", since = "1.63.0")] #[rustc_const_stable(feature = "const_slice_ptr_len_nonnull", since = "1.63.0")] - #[rustc_allow_const_fn_unstable(const_slice_ptr_len)] #[must_use] #[inline] pub const fn len(self) -> usize { @@ -1574,14 +1573,16 @@ impl NonNull<[T]> { /// # Examples /// /// ```rust - /// #![feature(slice_ptr_is_empty_nonnull)] /// use std::ptr::NonNull; /// /// let slice: NonNull<[i8]> = NonNull::slice_from_raw_parts(NonNull::dangling(), 3); /// assert!(!slice.is_empty()); /// ``` - #[unstable(feature = "slice_ptr_is_empty_nonnull", issue = "71146")] - #[rustc_const_unstable(feature = "const_slice_ptr_is_empty_nonnull", issue = "71146")] + #[stable(feature = "slice_ptr_is_empty_nonnull", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable( + feature = "const_slice_ptr_is_empty_nonnull", + since = "CURRENT_RUSTC_VERSION" + )] #[must_use] #[inline] pub const fn is_empty(self) -> bool { diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 0c87860096f63..e741149e7ce21 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -54,7 +54,6 @@ #![feature(sort_internals)] #![feature(slice_take)] #![feature(slice_from_ptr_range)] -#![feature(slice_ptr_len)] #![feature(slice_split_once)] #![feature(split_as_slice)] #![feature(maybe_uninit_fill)] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index ac475b5530a78..445f31ce49172 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -265,7 +265,6 @@ feature(slice_index_methods, coerce_unsized, sgx_platform) )] #![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))] -#![cfg_attr(target_os = "xous", feature(slice_ptr_len))] #![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))] #![cfg_attr( all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"), diff --git a/tests/ui/consts/const_fn_unsize.rs b/tests/ui/consts/const_fn_unsize.rs index f96a6088fd312..15d717e7e1213 100644 --- a/tests/ui/consts/const_fn_unsize.rs +++ b/tests/ui/consts/const_fn_unsize.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(slice_ptr_len)] use std::ptr::NonNull;