Suggestion to replace std::mem::uninitialized
with MaybeUninit is not actionable
#65432
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When
Foo
below is defined in a crate outside your control, code that currently does this:(Playground)
gets a warning suggesting to use
MaybeUninit
insteadThis warning is currently not actionable, since
Foo
cannot be modified, andMaybeUninit<T>
does not supportT: !Copy
.Instead, the suggestion "help: use
MaybeUninit<T>
instead" should only be shown ifT: Copy
.A different suggestion could be shown, suggesting to change the type definition instead, and maybe reminding the user that their code exhibits undefined behavior, even though there is nothing that the user might be able to do about this.
The text was updated successfully, but these errors were encountered: