Skip to content
/ rust Public
forked from rust-lang/rust

Commit 0518ecc

Browse files
authored
Rollup merge of rust-lang#123868 - eduardosm:stabilize-slice_ptr_len, r=jhpratt
Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull Stabilized API: ```rust impl<T> *mut [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> *const [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> NonNull<[T]> { pub const fn is_empty(self) -> bool; } ``` FCP completed in tracking issue: rust-lang#71146
2 parents 8533144 + fb9e1f7 commit 0518ecc

File tree

8 files changed

+16
-23
lines changed

8 files changed

+16
-23
lines changed

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@
151151
#![feature(slice_from_ptr_range)]
152152
#![feature(slice_index_methods)]
153153
#![feature(slice_ptr_get)]
154-
#![feature(slice_ptr_len)]
155154
#![feature(slice_range)]
156155
#![feature(std_internals)]
157156
#![feature(str_internals)]

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
#![feature(const_slice_from_raw_parts_mut)]
160160
#![feature(const_slice_from_ref)]
161161
#![feature(const_slice_index)]
162-
#![feature(const_slice_ptr_len)]
163162
#![feature(const_slice_split_at_mut)]
164163
#![feature(const_str_from_utf8_unchecked_mut)]
165164
#![feature(const_strict_overflow_ops)]

library/core/src/ptr/const_ptr.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1647,16 +1647,15 @@ impl<T> *const [T] {
16471647
/// # Examples
16481648
///
16491649
/// ```rust
1650-
/// #![feature(slice_ptr_len)]
1651-
///
16521650
/// use std::ptr;
16531651
///
16541652
/// let slice: *const [i8] = ptr::slice_from_raw_parts(ptr::null(), 3);
16551653
/// assert_eq!(slice.len(), 3);
16561654
/// ```
16571655
#[inline]
1658-
#[unstable(feature = "slice_ptr_len", issue = "71146")]
1659-
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
1656+
#[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1657+
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1658+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
16601659
pub const fn len(self) -> usize {
16611660
metadata(self)
16621661
}
@@ -1666,15 +1665,14 @@ impl<T> *const [T] {
16661665
/// # Examples
16671666
///
16681667
/// ```
1669-
/// #![feature(slice_ptr_len)]
16701668
/// use std::ptr;
16711669
///
16721670
/// let slice: *const [i8] = ptr::slice_from_raw_parts(ptr::null(), 3);
16731671
/// assert!(!slice.is_empty());
16741672
/// ```
16751673
#[inline(always)]
1676-
#[unstable(feature = "slice_ptr_len", issue = "71146")]
1677-
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
1674+
#[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1675+
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
16781676
pub const fn is_empty(self) -> bool {
16791677
self.len() == 0
16801678
}
@@ -1804,7 +1802,7 @@ impl<T, const N: usize> *const [T; N] {
18041802
/// # Examples
18051803
///
18061804
/// ```
1807-
/// #![feature(array_ptr_get, slice_ptr_len)]
1805+
/// #![feature(array_ptr_get)]
18081806
///
18091807
/// let arr: *const [i32; 3] = &[1, 2, 4] as *const [i32; 3];
18101808
/// let slice: *const [i32] = arr.as_slice();

library/core/src/ptr/mut_ptr.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1909,15 +1909,15 @@ impl<T> *mut [T] {
19091909
/// # Examples
19101910
///
19111911
/// ```rust
1912-
/// #![feature(slice_ptr_len)]
19131912
/// use std::ptr;
19141913
///
19151914
/// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3);
19161915
/// assert_eq!(slice.len(), 3);
19171916
/// ```
19181917
#[inline(always)]
1919-
#[unstable(feature = "slice_ptr_len", issue = "71146")]
1920-
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
1918+
#[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1919+
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1920+
#[rustc_allow_const_fn_unstable(ptr_metadata)]
19211921
pub const fn len(self) -> usize {
19221922
metadata(self)
19231923
}
@@ -1927,15 +1927,14 @@ impl<T> *mut [T] {
19271927
/// # Examples
19281928
///
19291929
/// ```
1930-
/// #![feature(slice_ptr_len)]
19311930
/// use std::ptr;
19321931
///
19331932
/// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3);
19341933
/// assert!(!slice.is_empty());
19351934
/// ```
19361935
#[inline(always)]
1937-
#[unstable(feature = "slice_ptr_len", issue = "71146")]
1938-
#[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
1936+
#[stable(feature = "slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
1937+
#[rustc_const_stable(feature = "const_slice_ptr_len", since = "CURRENT_RUSTC_VERSION")]
19391938
pub const fn is_empty(self) -> bool {
19401939
self.len() == 0
19411940
}

library/core/src/ptr/non_null.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1562,7 +1562,6 @@ impl<T> NonNull<[T]> {
15621562
/// ```
15631563
#[stable(feature = "slice_ptr_len_nonnull", since = "1.63.0")]
15641564
#[rustc_const_stable(feature = "const_slice_ptr_len_nonnull", since = "1.63.0")]
1565-
#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]
15661565
#[must_use]
15671566
#[inline]
15681567
pub const fn len(self) -> usize {
@@ -1574,14 +1573,16 @@ impl<T> NonNull<[T]> {
15741573
/// # Examples
15751574
///
15761575
/// ```rust
1577-
/// #![feature(slice_ptr_is_empty_nonnull)]
15781576
/// use std::ptr::NonNull;
15791577
///
15801578
/// let slice: NonNull<[i8]> = NonNull::slice_from_raw_parts(NonNull::dangling(), 3);
15811579
/// assert!(!slice.is_empty());
15821580
/// ```
1583-
#[unstable(feature = "slice_ptr_is_empty_nonnull", issue = "71146")]
1584-
#[rustc_const_unstable(feature = "const_slice_ptr_is_empty_nonnull", issue = "71146")]
1581+
#[stable(feature = "slice_ptr_is_empty_nonnull", since = "CURRENT_RUSTC_VERSION")]
1582+
#[rustc_const_stable(
1583+
feature = "const_slice_ptr_is_empty_nonnull",
1584+
since = "CURRENT_RUSTC_VERSION"
1585+
)]
15851586
#[must_use]
15861587
#[inline]
15871588
pub const fn is_empty(self) -> bool {

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
#![feature(sort_internals)]
5555
#![feature(slice_take)]
5656
#![feature(slice_from_ptr_range)]
57-
#![feature(slice_ptr_len)]
5857
#![feature(slice_split_once)]
5958
#![feature(split_as_slice)]
6059
#![feature(maybe_uninit_fill)]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@
265265
feature(slice_index_methods, coerce_unsized, sgx_platform)
266266
)]
267267
#![cfg_attr(any(windows, target_os = "uefi"), feature(round_char_boundary))]
268-
#![cfg_attr(target_os = "xous", feature(slice_ptr_len))]
269268
#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
270269
#![cfg_attr(
271270
all(any(target_arch = "x86_64", target_arch = "x86"), target_os = "uefi"),

tests/ui/consts/const_fn_unsize.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//@ run-pass
2-
#![feature(slice_ptr_len)]
32

43
use std::ptr::NonNull;
54

0 commit comments

Comments
 (0)