Skip to content

Stabilize new_zeroed_alloc #144091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ impl<T: Idx> ChunkedBitSet<T> {
};
#[cfg(not(feature = "nightly"))]
let mut words = {
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#63291).
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
// SAFETY: `words` can safely be all zeroes.
let words = unsafe { words.assume_init() };
Expand Down Expand Up @@ -704,7 +704,7 @@ impl<T: Idx> ChunkedBitSet<T> {
};
#[cfg(not(feature = "nightly"))]
let mut words = {
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#63291).
// FIXME: unconditionally use `Rc::new_zeroed` once it is stable (#129396).
let words = mem::MaybeUninit::<[Word; CHUNK_WORDS]>::zeroed();
// SAFETY: `words` can safely be all zeroes.
let words = unsafe { words.assume_init() };
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// tidy-alphabetical-start
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
#![cfg_attr(bootstrap, feature(new_zeroed_alloc))]
#![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))]
#![cfg_attr(feature = "nightly", feature(new_range_api))]
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
// tidy-alphabetical-end

pub mod bit_set;
Expand Down
16 changes: 2 additions & 14 deletions library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ impl<T> Box<T> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// let zero = Box::<u32>::new_zeroed();
/// let zero = unsafe { zero.assume_init() };
///
Expand All @@ -301,7 +299,7 @@ impl<T> Box<T> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed() -> Box<mem::MaybeUninit<T>> {
Self::new_zeroed_in(Global)
Expand Down Expand Up @@ -358,7 +356,6 @@ impl<T> Box<T> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, are these just stale comments? I'm a bit confused why we're deleting these in this PR...

Copy link
Contributor Author

@thaliaarchi thaliaarchi Jul 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments weren't updated when new_zeroed_alloc was split out of new_uninit, so half of them (e.g., try_new_zeroed) should be removed by this stabilization. Since the other half are already stable, but are closely related, it seems reasonable to fix them here.

#[inline]
pub fn try_new_uninit() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
Box::try_new_uninit_in(Global)
Expand All @@ -384,7 +381,6 @@ impl<T> Box<T> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn try_new_zeroed() -> Result<Box<mem::MaybeUninit<T>>, AllocError> {
Box::try_new_zeroed_in(Global)
Expand Down Expand Up @@ -463,7 +459,6 @@ impl<T, A: Allocator> Box<T, A> {
#[unstable(feature = "allocator_api", issue = "32838")]
#[cfg(not(no_global_oom_handling))]
#[must_use]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn new_uninit_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
where
A: Allocator,
Expand Down Expand Up @@ -496,7 +491,6 @@ impl<T, A: Allocator> Box<T, A> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_uninit_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
where
A: Allocator,
Expand Down Expand Up @@ -532,7 +526,6 @@ impl<T, A: Allocator> Box<T, A> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
#[cfg(not(no_global_oom_handling))]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[must_use]
pub fn new_zeroed_in(alloc: A) -> Box<mem::MaybeUninit<T>, A>
where
Expand Down Expand Up @@ -570,7 +563,6 @@ impl<T, A: Allocator> Box<T, A> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_zeroed_in(alloc: A) -> Result<Box<mem::MaybeUninit<T>, A>, AllocError>
where
A: Allocator,
Expand Down Expand Up @@ -660,8 +652,6 @@ impl<T> Box<[T]> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// let values = Box::<[u32]>::new_zeroed_slice(3);
/// let values = unsafe { values.assume_init() };
///
Expand All @@ -670,7 +660,7 @@ impl<T> Box<[T]> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
unsafe { RawVec::with_capacity_zeroed(len).into_box(len) }
Expand Down Expand Up @@ -785,7 +775,6 @@ impl<T, A: Allocator> Box<[T], A> {
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[must_use]
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
unsafe { RawVec::with_capacity_in(len, alloc).into_box(len) }
Expand Down Expand Up @@ -813,7 +802,6 @@ impl<T, A: Allocator> Box<[T], A> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[must_use]
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Box<[mem::MaybeUninit<T>], A> {
unsafe { RawVec::with_capacity_zeroed_in(len, alloc).into_box(len) }
Expand Down
16 changes: 2 additions & 14 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,6 @@ impl<T> Rc<T> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// use std::rc::Rc;
///
/// let zero = Rc::<u32>::new_zeroed();
Expand All @@ -527,7 +525,7 @@ impl<T> Rc<T> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed() -> Rc<mem::MaybeUninit<T>> {
unsafe {
Expand Down Expand Up @@ -589,7 +587,6 @@ impl<T> Rc<T> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_uninit() -> Result<Rc<mem::MaybeUninit<T>>, AllocError> {
unsafe {
Ok(Rc::from_ptr(Rc::try_allocate_for_layout(
Expand Down Expand Up @@ -622,7 +619,6 @@ impl<T> Rc<T> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
//#[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_zeroed() -> Result<Rc<mem::MaybeUninit<T>>, AllocError> {
unsafe {
Ok(Rc::from_ptr(Rc::try_allocate_for_layout(
Expand Down Expand Up @@ -690,7 +686,6 @@ impl<T, A: Allocator> Rc<T, A> {
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_uninit_in(alloc: A) -> Rc<mem::MaybeUninit<T>, A> {
unsafe {
Expand Down Expand Up @@ -728,7 +723,6 @@ impl<T, A: Allocator> Rc<T, A> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_zeroed_in(alloc: A) -> Rc<mem::MaybeUninit<T>, A> {
unsafe {
Expand Down Expand Up @@ -873,7 +867,6 @@ impl<T, A: Allocator> Rc<T, A> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn try_new_uninit_in(alloc: A) -> Result<Rc<mem::MaybeUninit<T>, A>, AllocError> {
unsafe {
Expand Down Expand Up @@ -912,7 +905,6 @@ impl<T, A: Allocator> Rc<T, A> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
//#[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn try_new_zeroed_in(alloc: A) -> Result<Rc<mem::MaybeUninit<T>, A>, AllocError> {
unsafe {
Expand Down Expand Up @@ -1054,8 +1046,6 @@ impl<T> Rc<[T]> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// use std::rc::Rc;
///
/// let values = Rc::<[u32]>::new_zeroed_slice(3);
Expand All @@ -1066,7 +1056,7 @@ impl<T> Rc<[T]> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
unsafe {
Expand Down Expand Up @@ -1129,7 +1119,6 @@ impl<T, A: Allocator> Rc<[T], A> {
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_uninit_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit<T>], A> {
unsafe { Rc::from_ptr_in(Rc::allocate_for_slice_in(len, &alloc), alloc) }
Expand Down Expand Up @@ -1158,7 +1147,6 @@ impl<T, A: Allocator> Rc<[T], A> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_zeroed_slice_in(len: usize, alloc: A) -> Rc<[mem::MaybeUninit<T>], A> {
unsafe {
Expand Down
14 changes: 2 additions & 12 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,6 @@ impl<T> Arc<T> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// use std::sync::Arc;
///
/// let zero = Arc::<u32>::new_zeroed();
Expand All @@ -529,7 +527,7 @@ impl<T> Arc<T> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed() -> Arc<mem::MaybeUninit<T>> {
unsafe {
Expand Down Expand Up @@ -603,7 +601,6 @@ impl<T> Arc<T> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_uninit() -> Result<Arc<mem::MaybeUninit<T>>, AllocError> {
unsafe {
Ok(Arc::from_ptr(Arc::try_allocate_for_layout(
Expand Down Expand Up @@ -636,7 +633,6 @@ impl<T> Arc<T> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
pub fn try_new_zeroed() -> Result<Arc<mem::MaybeUninit<T>>, AllocError> {
unsafe {
Ok(Arc::from_ptr(Arc::try_allocate_for_layout(
Expand Down Expand Up @@ -703,7 +699,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_uninit_in(alloc: A) -> Arc<mem::MaybeUninit<T>, A> {
unsafe {
Expand Down Expand Up @@ -741,7 +736,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn new_zeroed_in(alloc: A) -> Arc<mem::MaybeUninit<T>, A> {
unsafe {
Expand Down Expand Up @@ -927,7 +921,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn try_new_uninit_in(alloc: A) -> Result<Arc<mem::MaybeUninit<T>, A>, AllocError> {
unsafe {
Expand Down Expand Up @@ -966,7 +959,6 @@ impl<T, A: Allocator> Arc<T, A> {
///
/// [zeroed]: mem::MaybeUninit::zeroed
#[unstable(feature = "allocator_api", issue = "32838")]
// #[unstable(feature = "new_uninit", issue = "63291")]
#[inline]
pub fn try_new_zeroed_in(alloc: A) -> Result<Arc<mem::MaybeUninit<T>, A>, AllocError> {
unsafe {
Expand Down Expand Up @@ -1197,8 +1189,6 @@ impl<T> Arc<[T]> {
/// # Examples
///
/// ```
/// #![feature(new_zeroed_alloc)]
///
/// use std::sync::Arc;
///
/// let values = Arc::<[u32]>::new_zeroed_slice(3);
Expand All @@ -1210,7 +1200,7 @@ impl<T> Arc<[T]> {
/// [zeroed]: mem::MaybeUninit::zeroed
#[cfg(not(no_global_oom_handling))]
#[inline]
#[unstable(feature = "new_zeroed_alloc", issue = "129396")]
#[stable(feature = "new_zeroed_alloc", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
pub fn new_zeroed_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
unsafe {
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@
#![feature(allocator_api)]
#![feature(get_mut_unchecked)]
#![feature(map_try_insert)]
#![feature(new_zeroed_alloc)]
#![feature(slice_concat_trait)]
#![feature(thin_box)]
#![feature(try_reserve_kind)]
Expand Down
Loading