-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Use uninit checking from rustc #10520
Conversation
r? @Alexendoo (rustbot has picked a reviewer for you, use r? to override) |
833a265
to
4edb4d1
Compare
// edge case: For now we lint on empty arrays | ||
let _: [u8; 0] = unsafe { MaybeUninit::uninit().assume_init() }; | ||
|
||
// edge case: For now we accept unit tuples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also changed this comment because this isn't really a "for now", ZSTs are simply valid here.
rustc has proper heuristics for actually checking whether a type allows being left uninitialized (by asking CTFE). We can now use this for our helper instead of rolling our own bad version with false positives.
Great, thanks! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
I believe we've found a false-positive for this here. |
Uh, that's because this is a polymorphic type and we are conservative around polymorphic types and always say that they are wrong. |
In uninit checking, add fallback for polymorphic types After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit). fixes #10551 changelog: [uninit_vec]: fix false positive for polymorphic types changelog: [uninit_assumed_init]: fix false positive for polymorphic types
rustc has proper heuristics for actually checking whether a type allows being left uninitialized (by asking CTFE). We can now use this for our helper instead of rolling our own bad version with false positives.
I added this in rustc in rust-lang/rust#108669
Fix #10407
changelog: [
uninit_vec
]: fix false positiveschangelog: [
uninit_assumed_init
]: fix false positives