-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #![feature(maybe_uninit_extra,const_maybe_uninit_write)]
#63567
Comments
Latest status here: I am beginning to think that |
…fJung Adjust tracking issues for `MaybeUninit<T>` gates cc rust-lang#63566 rust-lang#63567 rust-lang#63568 rust-lang#63569 r? @RalfJung
…fJung Adjust tracking issues for `MaybeUninit<T>` gates cc rust-lang#63566 rust-lang#63567 rust-lang#63568 rust-lang#63569 r? @RalfJung
That depends on whether references to invalid data are UB or not. If yes, then certainly. If not, then maybe. Currently they are UB but that's just because it is the more conservative choice. |
…it-drop, r=RalfJung Add MaybeUninit::assume_init_drop. `ManuallyDrop`'s documentation tells the user to use `MaybeUninit` instead when handling uninitialized data. However, the main functionality of `ManuallyDrop` (`drop`) is not available directly on `MaybeUninit`. Adding it makes it easier to switch from one to the other. I re-used the `maybe_uninit_extra` feature and tracking issue number (rust-lang#63567), since it seems very related. (And to avoid creating too many features tracking issues for `MaybeUninit`.)
…it-drop, r=RalfJung Add MaybeUninit::assume_init_drop. `ManuallyDrop`'s documentation tells the user to use `MaybeUninit` instead when handling uninitialized data. However, the main functionality of `ManuallyDrop` (`drop`) is not available directly on `MaybeUninit`. Adding it makes it easier to switch from one to the other. I re-used the `maybe_uninit_extra` feature and tracking issue number (rust-lang#63567), since it seems very related. (And to avoid creating too many features tracking issues for `MaybeUninit`.)
What stands in the way of stabilizing this? |
Hm, good question. I'd list these:
|
I don't know whether this is an actual problem, but yes, it has the same issue: playground link BTW, the underlying In the latter case it is arguably worse, because the method name contains For me, the real question is: what are the semantics of assigning to a I assume that when I'm assigning a new value, the old one will be guaranteed to be dropped. But what about the new value? Is the new value guaranteed to be dropped at some point? If yes, this issue is an actual problem. But AFAICT, it is allowed in safe Rust to call Still, I'm not sure whether accidental leaking should be made that easy? |
We already have stable |
Why do you think |
I guess the problem is that the function name Therefore, in my (limited) experience with stable Rust, I've come to imagine that That is fine as long as there is only a single function containing the words "assume init". I've looked back to the discussions about naming Now that we have a stable function |
I am rather surprised by this. Whether or not the destructor runs is fully encoded in the type -- when a
I disagree -- I think having more of these methods will actually make this more clear. Once |
I think in other words, the confusion is that |
Sorry that I'm using such naive and hand-wavey terminology. But that's how I, as a humble Rust user, think about it. I have a
That's true, but also because But anyway, I'm wondering: why do we even need Aren't they just wrappers for one-liners? I have the feeling that adding all those function will make Rust more complicated without really gaining anything. I think using the one-liners directly makes it much more obvious to see what actually happens in the code.
I don't think this is similar at all. The function name Casting from a pointer to a reference isn't similar either. It is done by using sigils alone and doesn't involve any function names at all. |
Well, the main meaning (I'd say) is that initialization is done and the compiler may now assume that the data is initialized. So I don't think meaning is "stripped". But anyway, this is useful feedback, even if I don't quite know what to do with it. ;) Thanks! |
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. This will be merged soon. |
AFAICT, no PR was sent for this. Sending one for the |
This covers: impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: rust-lang#63567 (comment). Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
… r=Mark-Simulacrum Partially stabilize `maybe_uninit_extra` This covers: ```rust impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } ``` It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: rust-lang#63567 (comment). Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
… r=Mark-Simulacrum Partially stabilize `maybe_uninit_extra` This covers: ```rust impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } ``` It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: rust-lang#63567 (comment). Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
… r=Mark-Simulacrum Partially stabilize `maybe_uninit_extra` This covers: ```rust impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } ``` It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: rust-lang#63567 (comment). Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Why is it called |
Yes, there are other |
To me it's a natural combination of |
What about the stabilization of |
That's blocked on stabilizing any use of |
Opened #116233 to const-stabilize |
…it_assume_init_read, r=dtolnay Stabilize `const_maybe_uninit_assume_init_read` AFAICT the only reason this was not included in the `maybe_uninit_extra` stabilization was because `ptr::read` was unstable (rust-lang#92768 (comment)), which has since been stabilized in 1.71. Needs a separate FCP from the [original `maybe_uninit_extra` one](rust-lang#63567 (comment)). Tracking issue: rust-lang#63567
…_init_read, r=dtolnay Stabilize `const_maybe_uninit_assume_init_read` AFAICT the only reason this was not included in the `maybe_uninit_extra` stabilization was because `ptr::read` was unstable (rust-lang/rust#92768 (comment)), which has since been stabilized in 1.71. Needs a separate FCP from the [original `maybe_uninit_extra` one](rust-lang/rust#63567 (comment)). Tracking issue: #63567
Mark the following API const stable: impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } This depends on `const_mut_refs` and `const_maybe_uninit_assume_init`, both of which have recently been stabilized. Tracking issue: <rust-lang#63567>
Mark the following API const stable: impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } This depends on `const_mut_refs` and `const_maybe_uninit_assume_init`, both of which have recently been stabilized. Tracking issue: <rust-lang#63567>
Mark the following API const stable: impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } This depends on `const_mut_refs` and `const_maybe_uninit_assume_init`, both of which have recently been stabilized. Tracking issue: <rust-lang#63567>
…nit_write, r=RalfJung,dtolnay Stabilize `const_maybe_uninit_write` Mark the following API const stable: ```rust impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } ``` This depends on `const_mut_refs` and [`const_maybe_uninit_assume_init`](rust-lang#86722), both of which have recently been stabilized. Closes: <rust-lang#63567>
Rollup merge of rust-lang#131713 - tgross35:stabilize-const_maybe_uninit_write, r=RalfJung,dtolnay Stabilize `const_maybe_uninit_write` Mark the following API const stable: ```rust impl<T> MaybeUninit<T> { pub const fn write(&mut self, val: T) -> &mut T; } ``` This depends on `const_mut_refs` and [`const_maybe_uninit_assume_init`](rust-lang#86722), both of which have recently been stabilized. Closes: <rust-lang#63567>
This is a tracking issue for the RFC "Deprecate
uninitialized
in favor of a newMaybeUninit
type" (rust-lang/rfcs#1892).This issue specifically tracks the following unstable methods:
and it tracks const-ness of
The text was updated successfully, but these errors were encountered: