You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since I found a few of these while working on rust-lang/rust#129259, this feels like a decent lint.
Assuming that this will be worked on after that PR is merged, it should detect both MaybeUninit::assume_init_mut and <[MaybeUninit<_>]>::assume_init_mut.
Advantage
Removes need to import drop_in_place in many cases
Fewer method calls = better codegen
Probably easier to read due to being shorter
Drawbacks
It could be difficult to detect all cases, e.g. binding the assume_init_mut value to a variable and then calling drop_in_place.
Example
Essentially, it would look for calls of the form:
ptr::drop_in_place(x.assume_init_mut())
and replace them with:
x.assume_init_drop()
We probably also want to cover the simple case of:
let y = x.assume_init_mut();
ptr::drop_in_place(y);
And… well, if y is used after that, this would be UB anyway, so, I'm going to assume that it's okay to replace this with:
x.assume_init_drop()
The text was updated successfully, but these errors were encountered:
What it does
Since I found a few of these while working on rust-lang/rust#129259, this feels like a decent lint.
Assuming that this will be worked on after that PR is merged, it should detect both
MaybeUninit::assume_init_mut
and<[MaybeUninit<_>]>::assume_init_mut
.Advantage
drop_in_place
in many casesDrawbacks
It could be difficult to detect all cases, e.g. binding the
assume_init_mut
value to a variable and then callingdrop_in_place
.Example
Essentially, it would look for calls of the form:
and replace them with:
We probably also want to cover the simple case of:
And… well, if
y
is used after that, this would be UB anyway, so, I'm going to assume that it's okay to replace this with:The text was updated successfully, but these errors were encountered: