Uh oh!
There was an error while loading. Please reload this page.
Partially stabilize box_vec_non_null - #157226
Conversation
An additional issue: Should EDIT: It could also be |
clarfonthey
commented
Jun 2, 2026
Just cataloguing the similar methods from rustdoc:
from_parts/into_parts: (proposed)
I think that The only other methods in libstd that use the term "parts" are Would say that maybe we should not label any "parts" as canonical for now at least, since it's not clear what version would be best to use. |
nia-e
commented
Jun 2, 2026
cc @rust-lang/opsem - is there a reason on your end to make |
joshtriplett
commented
Jun 2, 2026
@joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Which exact function is this about? EDIT: I assume Though given that the returned pointer is meant to be mutable, my personal preference would be |
BurntSushi
commented
Jun 2, 2026
I like these. I'm concerned about the @rfcbot concern |
theemathas
commented
Jun 3, 2026
Just to confirm: T-libs-api has agreed to stabilize with the name @BurntSushi The reason the |
BurntSushi
commented
Jun 3, 2026
@theemathas Not sure if anything has changed or if it has been discussed. That comment is from almost 2 years ago though. @joshtriplett Thoughts on the naming here? |
nia-e
commented
Jun 3, 2026
I think we have generally agreed in the past that non-null is |
nia-e
commented
Jun 12, 2026
To resolve the |
@nia-e I assume this also means:
|
This makes the `dangling_pointers_from_temporaries` lint work with it.
24e92dc to
a18a972Comparerustbot
commented
Jun 13, 2026
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
theemathas
commented
Jun 24, 2026
@riking As currently implemented, both |
joshtriplett
commented
Jul 7, 2026
@BurntSushi wrote:
I've seen various FFI code that uses I think You can't declare your FFI interface to take On that specific basis, I think |
BurntSushi
commented
Jul 14, 2026
I'm convinced by @joshtriplett's argument here. And in particular, that FFI code is not commonly concerning itself with whether a pointer is aligned or not. @rfcbot resolve |
rust-rfcbot
commented
Jul 14, 2026
🔔 This is now entering its final comment period, as per the review above. 🔔 |
rust-rfcbot
commented
Jul 24, 2026
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
nia-e
commented
Jul 28, 2026
r? me @bors r+ |
Rollup of 11 pull requests Successful merges: - #158168 (Added implementation on `set_permissions_nofollow` for all primary platforms) - #160055 (Simplify `MaybeRequiresStorage`) - #157226 (Partially stabilize `box_vec_non_null`) - #158879 (simplify `slice::Iter[Mut]::next_chunk` implementation) - #159413 (Enable `#[diagnostic::on_unknown]` during late res) - #160091 (Fix rustdoc toolbar height when title is taller than one line) - #158615 (fix: don't fire `explicit_outlives_requirements` on `?Sized` type params) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #160032 (rustdoc-json: Make `Stability` compatible with non-self-describing serde formats) - #160039 (Add regression test for enum unconstrained parameter ) - #160049 (Use assert_eq! in splat codegen tests)
Rollup of 11 pull requests Successful merges: - #158168 (Added implementation on `set_permissions_nofollow` for all primary platforms) - #160055 (Simplify `MaybeRequiresStorage`) - #157226 (Partially stabilize `box_vec_non_null`) - #158879 (simplify `slice::Iter[Mut]::next_chunk` implementation) - #159413 (Enable `#[diagnostic::on_unknown]` during late res) - #160091 (Fix rustdoc toolbar height when title is taller than one line) - #158615 (fix: don't fire `explicit_outlives_requirements` on `?Sized` type params) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #160032 (rustdoc-json: Make `Stability` compatible with non-self-describing serde formats) - #160039 (Add regression test for enum unconstrained parameter ) - #160049 (Use assert_eq! in splat codegen tests)
Uh oh!
There was an error while loading. Please reload this page.
Rollup merge of #157226 - theemathas:stab-box-vec-non-null, r=nia-e Partially stabilize `box_vec_non_null` Closes#130364 r? libs-api ### What's being stabilized The following is being stabilized in this PR: ```rust impl<T: ?Sized> Box<T> { pub unsafe fn from_non_null(ptr: NonNull<T>) -> Self { .... } pub fn into_non_null(b: Self) -> NonNull<T> { .... } } impl<T> Vec<T> { pub const unsafe fn from_parts(ptr: NonNull<T>, length: usize, capacity: usize) -> Self { .... } pub const fn into_parts(self) -> (NonNull<T>, usize, usize) { .... } } ``` Note that `Vec::from_parts` and `Vec::into_parts` remain const-unstable behind the `const_heap` feature (like `Vec::from_raw_parts` and `Vec::into_raw_parts`). The following APIs remain gated behind `allocator_api` ```rust impl<T: ?Sized, A: Allocator> Box<T, A> { pub unsafe fn from_non_null_in(raw: NonNull<T>, alloc: A) -> Self { .... } pub fn into_non_null_with_allocator(b: Self) -> (NonNull<T>, A) { .... } } impl<T, A: Allocator> Vec<T, A> { pub const unsafe fn from_parts_in(ptr: NonNull<T>, length: usize, capacity: usize, alloc: A) -> Self { .... } pub const fn into_parts_with_alloc(self) -> (NonNull<T>, usize, usize, A) { .... } } ``` The following API is split into a new unstable feature in #157843, and remains unstable: ```rust impl<T, A: Allocator> Vec<T, A> { pub const fn as_non_null(&mut self) -> NonNull<T> { .... } } ``` ### Implementation History Most of this feature was ACP'ed in rust-lang/libs-team#418, and implemented in #130061. `Vec::as_non_null` was ACP'ed separately in rust-lang/libs-team#440, and implemented in #130624. ### Potential issues * Should `Vec::from_parts` and `Vec::into_parts` be the name used for this? Or should those names be used for functions that take/return `Box<[MaybeUninit<T>]>`? (Raised at #130364 (comment)) * Should these function names be named `non_null` or `nonnull`? (Raised at #130364 (comment). See #154237 (comment).) * Will the methods on `Vec` collide with anything via autoderef?
Confusing that |
clarfonthey
commented
Jul 30, 2026
Yes: #157226 (comment) |
View all comments
Closes#130364
r? libs-api
What's being stabilized
The following is being stabilized in this PR:
Note that
Vec::from_partsandVec::into_partsremain const-unstable behind theconst_heapfeature (likeVec::from_raw_partsandVec::into_raw_parts).The following APIs remain gated behind
allocator_apiThe following API is split into a new unstable feature in #157843, and remains unstable:
Implementation History
Most of this feature was ACP'ed in rust-lang/libs-team#418, and implemented in #130061.
Vec::as_non_nullwas ACP'ed separately in rust-lang/libs-team#440, and implemented in #130624.Potential issues
Vec::from_partsandVec::into_partsbe the name used for this? Or should those names be used for functions that take/returnBox<[MaybeUninit<T>]>? (Raised at Tracking Issue forbox_vec_non_null#130364 (comment))non_nullornonnull? (Raised at Tracking Issue forbox_vec_non_null#130364 (comment). Seemem::Alignment: Naming the-> NonZero<usize>method. #154237 (comment).)Veccollide with anything via autoderef?