library: Move unstable API of new_uninit to new features

- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as
it was decided to only stabilize `uninit*` and `assume_init`.
This commit is contained in:
Jubilee Young 2024-08-21 22:32:03 -07:00
parent a32d4a0e82
commit 9ccd7abefe
5 changed files with 18 additions and 9 deletions

View File

@ -2,6 +2,7 @@
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))] #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(extend_one, new_uninit, step_trait, test))] #![cfg_attr(feature = "nightly", feature(extend_one, new_uninit, step_trait, test))]
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod bit_set; pub mod bit_set;

View File

@ -293,6 +293,7 @@ pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
/// ///
/// ``` /// ```
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// #![feature(new_zeroed_alloc)]
/// ///
/// let zero = Box::<u32>::new_zeroed(); /// let zero = Box::<u32>::new_zeroed();
/// let zero = unsafe { zero.assume_init() }; /// let zero = unsafe { zero.assume_init() };
@ -303,7 +304,7 @@ pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[inline] #[inline]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> { pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
Self::new_zeroed_in(Global) Self::new_zeroed_in(Global)
@ -684,6 +685,7 @@ pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// ///
/// let values = Box::<[u32]>::new_zeroed_slice(3); /// let values = Box::<[u32]>::new_zeroed_slice(3);
@ -694,7 +696,7 @@ pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
/// ///
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
unsafe { RawVec::with_capacity_zeroed(len).into_box(len) } unsafe { RawVec::with_capacity_zeroed(len).into_box(len) }
@ -955,6 +957,7 @@ pub unsafe fn assume_init(self) -> Box<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(box_uninit_write)]
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// ///
/// let big_box = Box::<[usize; 1024]>::new_uninit(); /// let big_box = Box::<[usize; 1024]>::new_uninit();
@ -972,7 +975,7 @@ pub unsafe fn assume_init(self) -> Box<T, A> {
/// assert_eq!(*x, i); /// assert_eq!(*x, i);
/// } /// }
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "box_uninit_write", issue = "129397")]
#[inline] #[inline]
pub fn write(mut boxed: Self, value: T) -> Box<T, A> { pub fn write(mut boxed: Self, value: T) -> Box<T, A> {
unsafe { unsafe {

View File

@ -539,6 +539,7 @@ pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -551,7 +552,7 @@ pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> {
/// ///
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> { pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> {
unsafe { unsafe {
@ -1000,6 +1001,7 @@ pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
/// ///
/// ``` /// ```
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// #![feature(new_zeroed_alloc)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
@ -1011,7 +1013,7 @@ pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
/// ///
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> { pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
unsafe { unsafe {

View File

@ -542,6 +542,7 @@ pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -555,7 +556,7 @@ pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> {
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[inline] #[inline]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> { pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> {
unsafe { unsafe {
@ -1134,6 +1135,7 @@ pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)] /// #![feature(new_uninit)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -1147,7 +1149,7 @@ pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[inline] #[inline]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[must_use] #[must_use]
pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> { pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
unsafe { unsafe {
@ -1191,7 +1193,7 @@ impl<T, A: Allocator> Arc<[T], A> {
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "allocator_api", issue = "32838")]
#[inline] #[inline]
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit<T>], A> { pub fn new_uninit_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit<T>], A> {
unsafe { Arc::from_ptr_in(Arc::allocate_for_slice_in(len, &alloc), alloc) } unsafe { Arc::from_ptr_in(Arc::allocate_for_slice_in(len, &alloc), alloc) }
@ -1220,7 +1222,7 @@ pub fn new_uninit_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit<T>], A
/// ///
/// [zeroed]: mem::MaybeUninit::zeroed /// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[unstable(feature = "allocator_api", issue = "32838")]
#[inline] #[inline]
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit<T>], A> { pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Arc<[mem::MaybeUninit<T>], A> {
unsafe { unsafe {

View File

@ -363,6 +363,7 @@
#![feature(get_mut_unchecked)] #![feature(get_mut_unchecked)]
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![feature(new_uninit)] #![feature(new_uninit)]
#![feature(new_zeroed_alloc)]
#![feature(slice_concat_trait)] #![feature(slice_concat_trait)]
#![feature(thin_box)] #![feature(thin_box)]
#![feature(try_reserve_kind)] #![feature(try_reserve_kind)]