Skip to content
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

(clippy::uninit_assumed_init): this call for this type may be undefined behavior #105

Open
pymongo opened this issue Jan 27, 2021 · 1 comment

Comments

@pymongo
Copy link
Contributor

pymongo commented Jan 27, 2021

let mut arr: [u8; 12] = unsafe { MaybeUninit::uninit().assume_init() };

should change to

let mut arr: [MaybeUninit<u8>; 12] = unsafe { MaybeUninit::uninit().assume_init() };

or

let mut arr = [0u8; 12];

error: this call for this type may be undefined behavior
   --> src/value.rs:129:42
    |
129 |         let mut arr: [u8; 12] = unsafe { MaybeUninit::uninit().assume_init() };
    |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[deny(clippy::uninit_assumed_init)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninit_assumed_init
@BusyJay
Copy link
Member

BusyJay commented Jan 27, 2021

I think it's over-warning in this specific case. u8 is never read from and it doesn't implement Drop, it should be safe to assume init. But I'm also OK to change it to meet best practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants