Skip to content

Commit

Permalink
Rollup merge of rust-lang#130214 - RalfJung:zeroed, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
MaybeUninit::zeroed: mention that padding is not zeroed

That should clarify cases like [this](rust-lang#129778 (comment)).
  • Loading branch information
Zalathar authored Sep 15, 2024
2 parents 13d21df + d4ac759 commit 235644f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ impl<T> MaybeUninit<T> {
/// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not
/// be null.
///
/// Note that if `T` has padding bytes, those bytes are *not* preserved when the
/// `MaybeUninit<T>` value is returned from this function, so those bytes will *not* be zeroed.
///
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
///
Expand Down

0 comments on commit 235644f

Please sign in to comment.