remove unsound MaybeUninitSlice::from_init_mut
and useless `...::fr…
#21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…om_init`
Well, that's weird. I've had a safety comment:
But it's wrong.
&mut T
andT
isn't the same thing. While it's true thatT => MaybeUninit<T>
or the same for an owned container (array, box, etc) should be fine, for an unique borrowed
container (
&mut _
,&mut [_]
) it is definitely not fine, because the original owned valueremains
T
. Example of such a UB in safe code:You can also think of
MaybeUninit<T>
as a supertype ofT
andthen note that
&mut T
is invariant overT
: https://doc.rust-lang.org/nomicon/subtyping.html#varianceThe weirdest part of all of this is that I haven't tested those functions.
There aren't any tests. There aren't any test for safe function with unsafe in it!
I am ashamed...
A related issue in
rust-lang
repo, about documenting unsoundnessof
&mut T => &mut MaybeUninit<T>
: rust-lang/rust#66699