blob: cca24093d40df18204fc5403e74a9801767fa76c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
### 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()
};
```
|