clippy doesn't properly model whether a type is allowed to be uninit #10407
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
The
uninit_vec
anduninit_assumed_init
lints use a helper to check whether a type may be uninit.rust-clippy/clippy_utils/src/ty.rs
Lines 541 to 548 in 3d193fa
This helper is incorrect for newtypes around
MaybeUninit<T>
, ZSTs and unions in general.This should be fixed by just deleting this helper function and using rustc's
check_validity_of_init
(the name may change in rust-lang/rust#108505). It doesn't currently support uninit checks but that should be really easy to add upstream (and needed for rust-lang/rust#100423 anyways).Lint Name
uninit_vec,uninit_assumed_init
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: Everything is fine
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: