Rollup merge of #130214 - RalfJung:zeroed, r=Mark-Simulacrum

MaybeUninit::zeroed: mention that padding is not zeroed

That should clarify cases like [this](https://github.com/rust-lang/rust/pull/129778#issuecomment-2342542847).
This commit is contained in:
Stuart Cook 2024-09-15 12:14:56 +10:00 committed by GitHub
commit 0648987532
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -351,6 +351,9 @@ pub const fn uninit() -> 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.
///