Skip to content
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

Tracking Issue for new_zeroed_alloc #129396

Open
2 tasks
workingjubilee opened this issue Aug 22, 2024 · 1 comment
Open
2 tasks

Tracking Issue for new_zeroed_alloc #129396

workingjubilee opened this issue Aug 22, 2024 · 1 comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@workingjubilee
Copy link
Member

workingjubilee commented Aug 22, 2024

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

Unresolved Questions

  • idk lol

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@workingjubilee workingjubilee added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Aug 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 26, 2024
…n-of-stabilization, r=<try>

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang#63291 (comment)

The following API has been stabilized from rust-lang#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang#129396
- `box_uninit_write`: rust-lang#129397

All relevant code is thus either stabilized or split out of that issue, so this closes rust-lang#63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 27, 2024
…ion-of-stabilization, r=dtolnay

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang#63291 (comment)

The following API has been stabilized from rust-lang#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang#129396
- `box_uninit_write`: rust-lang#129397

All relevant code is thus either stabilized or split out of that issue, so this closes rust-lang#63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 29, 2024
…ion-of-stabilization, r=dtolnay,joboet

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang#63291 (comment)

The following API has been stabilized from rust-lang#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang#129396
- `box_uninit_write`: rust-lang#129397

All relevant code is thus either stabilized or split out of that issue, so this closes rust-lang#63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 29, 2024
…ion-of-stabilization, r=dtolnay,joboet

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang#63291 (comment)

The following API has been stabilized from rust-lang#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang#129396
- `box_uninit_write`: rust-lang#129397

All relevant code is thus either stabilized or split out of that issue, so this closes rust-lang#63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 29, 2024
Rollup merge of rust-lang#129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang#63291 (comment)

The following API has been stabilized from rust-lang#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang#129396
- `box_uninit_write`: rust-lang#129397

All relevant code is thus either stabilized or split out of that issue, so this closes rust-lang#63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Aug 30, 2024
…abilization, r=dtolnay,joboet

Partially stabilize `feature(new_uninit)`

Finished comment period: rust-lang/rust#63291 (comment)

The following API has been stabilized from rust-lang/rust#63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: rust-lang/rust#129396
- `box_uninit_write`: rust-lang/rust#129397

All relevant code is thus either stabilized or split out of that issue, so this closes #63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
wasv added a commit to wasv/dust that referenced this issue Oct 10, 2024
Needed in order to build with newest nightly

More specific version of new_uninit as introduced in

rust-lang/rust#129396
wasv added a commit to wasv/emu-utils that referenced this issue Oct 10, 2024
Needed in order to build with newest nightly

More specific version of new_uninit introduced in rust-lang/rust#129396
davide125 added a commit to davide125/m1n1 that referenced this issue Oct 30, 2024
```
warning: the feature `new_uninit` has been stable since 1.82.0 and no longer requires an attribute to enable
 --> src/lib.rs:5:12
  |
5 | #![feature(new_uninit)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default
error[E0658]: use of unstable library feature 'new_zeroed_alloc'
  --> src/nvme.rs:20:41
   |
20 |     let p: Box<SectorBuffer> = unsafe { Box::new_zeroed().assume_init() };
   |                                         ^^^^^^^^^^^^^^^
   |
   = note: see issue #129396 <rust-lang/rust#129396> for more information
   = help: add `#![feature(new_zeroed_alloc)]` to the crate attributes to enable
```
davide125 added a commit to davide125/m1n1 that referenced this issue Oct 30, 2024
```
warning: the feature `new_uninit` has been stable since 1.82.0 and no longer requires an attribute to enable
 --> src/lib.rs:5:12
  |
5 | #![feature(new_uninit)]
  |            ^^^^^^^^^^
  |
  = note: `#[warn(stable_features)]` on by default
error[E0658]: use of unstable library feature 'new_zeroed_alloc'
  --> src/nvme.rs:20:41
   |
20 |     let p: Box<SectorBuffer> = unsafe { Box::new_zeroed().assume_init() };
   |                                         ^^^^^^^^^^^^^^^
   |
   = note: see issue #129396 <rust-lang/rust#129396> for more information
   = help: add `#![feature(new_zeroed_alloc)]` to the crate attributes to enable
```

Signed-off-by: Davide Cavalca <[email protected]>
@coolreader18
Copy link
Contributor

This seems pretty straightforward - are there any blockers to stabilizing this as-is? It's a mirror of the new_uninit API family, in the same way that MaybeUninit has both uninit() and zeroed(), so it's following established patterns and logically filling out the set of APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants