RS.CLIPPY.UNINIT_ASSUMED_INIT
`MaybeUninit::uninit().assume_init()`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: uninit_assumed_init. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for MaybeUninit::uninit().assume_init().
Why is this bad?
For most types, this is undefined behavior.
Known problems
For now, we accept empty tuples and tuples / arrays
of MaybeUninit. There may be other types that allow uninitialized
data, but those are not yet rigorously defined.
Example
// Beware the UB
use std::mem::MaybeUninit;
let _: usize = unsafe { MaybeUninit::uninit().assume_init() };
Note that the following is OK:
use std::mem::MaybeUninit;
let _: [MaybeUninit<bool>; 5] = unsafe {
MaybeUninit::uninit().assume_init()
};