This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-11
lines changed Expand file tree Collapse file tree 2 files changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,6 @@ use crate::slice;
5454/// // The equivalent code with `MaybeUninit<i32>`:
5555/// let x: i32 = unsafe { MaybeUninit::uninit().assume_init() }; // undefined behavior! ⚠️
5656/// ```
57- /// (Notice that the rules around uninitialized integers are not finalized yet, but
58- /// until they are, it is advisable to avoid them.)
59- ///
6057/// On top of that, remember that most types have additional invariants beyond merely
6158/// being considered initialized at the type level. For example, a `1`-initialized [`Vec<T>`]
6259/// 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 {
665665/// correctly: it has the same effect as [`MaybeUninit::uninit().assume_init()`][uninit].
666666/// As the [`assume_init` documentation][assume_init] explains,
667667/// [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.
676671///
677672/// [uninit]: MaybeUninit::uninit
678673/// [assume_init]: MaybeUninit::assume_init
You can’t perform that action at this time.
0 commit comments