Repository navigation
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(new_zeroed_alloc)]
Split-out from #63291 as a result of stabilizing most of its API! It's zeroed instead of uninit constructors, nothing too complicated!
Public API
It's new_zeroed and new_zeroed_slice on every major allocation type like Box, Rc, Arc.
impl<T> Box<T> { pub fn new_zeroed() -> Box<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_zeroed() -> Arc<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_zeroed() -> Rc<MaybeUninit<T>> {…} }
impl<[T]> Box<T> { pub fn new_zeroed_slice() -> Box<MaybeUninit<[T]>> {…} }
impl<[T]> Arc<T> { pub fn new_zeroed_slice() -> Arc<MaybeUninit<[T]>> {…} }
impl<[T]> Rc<T> { pub fn new_zeroed_slice() -> Rc<MaybeUninit<[T]>> {…} }Steps / History
- Implementation: #...
- added in alloc: Add new_zeroed() versions like new_uninit(). #66128
- other API was added in Tracking issue for uninitialized constructors for Box, Rc, Arc #63291
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- idk lol
Footnotes
Reacted by Nazar Mokrynskyi, Vilim Lendvaj and Thalia Archibald
Reacted by Khyber Sen, Gabriel Bjørnager Jensen, José Luis Cruz, Tayfun Bocek, Okeyer, Vilim Lendvaj, Thalia Archibald and orzogc
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Activity
Auto merge of rust-lang#129401 - workingjubilee:partial-initializatio…
Rollup merge of rust-lang#129401 - workingjubilee:partial-initializat…
Rollup merge of rust-lang#129401 - workingjubilee:partial-initializat…
Rollup merge of rust-lang#129401 - workingjubilee:partial-initializat…
Unrolled build for rust-lang#129401
Rollup merge of #129401 - workingjubilee:partial-initialization-of-st…
Fix build failure in Fedora
Fix build failure in Fedora
coolreader18 commentedon Nov 20, 2024
This seems pretty straightforward - are there any blockers to stabilizing this as-is? It's a mirror of the
new_uninitAPI family, in the same way thatMaybeUninithas bothuninit()andzeroed(), so it's following established patterns and logically filling out the set of APIs.thaliaarchi commentedon Jul 17, 2025
I think this feature is ready, so have opened #144091 to stabilize this.
Stabilization report
The corresponding
new_uninitandnew_uninit_slicefunctions were stabilized in #129401, but the zeroed counterparts were left for later out of a desire to stabilize only the minimal set. These functions are straightforward mirrors of the uninit functions and well-established. Since no blockers or design questions have surfaced in the past year, I think it's time to stabilize them.Auto merge of #144091 - thaliaarchi:stabilize-new-zeroed, r=Mark-Simu…
Rollup merge of rust-lang#144091 - thaliaarchi:stabilize-new-zeroed, …
Rollup merge of rust-lang#144091 - thaliaarchi:stabilize-new-zeroed, …
Auto merge of #144091 - thaliaarchi:stabilize-new-zeroed, r=Mark-Simu…
Auto merge of #144091 - thaliaarchi:stabilize-new-zeroed, r=Mark-Simu…
Rollup merge of rust-lang#144091 - thaliaarchi:stabilize-new-zeroed, …
Unrolled build for #144091
Rollup merge of rust-lang#144091 - thaliaarchi:stabilize-new-zeroed, …
Rollup merge of rust-lang#144091 - thaliaarchi:stabilize-new-zeroed, …