File tree 2 files changed +3
-11
lines changed
2 files changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,6 @@ use crate::slice;
54
54
/// // The equivalent code with `MaybeUninit<i32>`:
55
55
/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
56
56
/// ```
57
- /// (Notice that the rules around uninitialized integers are not finalized yet, but
58
- /// until they are, it is advisable to avoid them.)
59
- ///
60
57
/// On top of that, remember that most types have additional invariants beyond merely
61
58
/// being considered initialized at the type level. For example, a `1`-initialized [`Vec<T>`]
62
59
/// is considered initialized (under the current implementation; this does not constitute
Original file line number Diff line number Diff line change @@ -665,14 +665,9 @@ pub unsafe fn zeroed<T>() -> T {
665
665
/// correctly: it has the same effect as [`MaybeUninit::uninit().assume_init()`][uninit].
666
666
/// As the [`assume_init` documentation][assume_init] explains,
667
667
/// [the Rust compiler assumes][inv] that values are properly initialized.
668
- /// As a consequence, calling e.g. `mem::uninitialized::<bool>()` causes immediate
669
- /// undefined behavior for returning a `bool` that is not definitely either `true`
670
- /// or `false`. Worse, truly uninitialized memory like what gets returned here
671
- /// is special in that the compiler knows that it does not have a fixed value.
672
- /// This makes it undefined behavior to have uninitialized data in a variable even
673
- /// if that variable has an integer type.
674
- /// (Notice that the rules around uninitialized integers are not finalized yet, but
675
- /// until they are, it is advisable to avoid them.)
668
+ ///
669
+ /// Therefore, it is immediate undefined behavior to call this function on nearly all types,
670
+ /// including integer types and arrays of integer types, and even if the result is unused.
676
671
///
677
672
/// [uninit]: MaybeUninit::uninit
678
673
/// [assume_init]: MaybeUninit::assume_init
You can’t perform that action at this time.
0 commit comments