be explicit that mem::uninitialized is the same as MaybeUninit::uninit().assume_init()
This commit is contained in:
parent
9409c208a9
commit
216b9ae878
@ -510,7 +510,9 @@ pub unsafe fn zeroed<T>() -> T {
|
||||
/// **This function is deprecated.** Use [`MaybeUninit<T>`] instead.
|
||||
///
|
||||
/// The reason for deprecation is that the function basically cannot be used
|
||||
/// correctly: [the Rust compiler assumes][inv] that values are properly initialized.
|
||||
/// correctly: it has the same effect as [`MaybeUninit::uninit().assume_init()`][uninit].
|
||||
/// As the [`assume_init` documentation][assume_init] explains,
|
||||
/// [the Rust compiler assumes][inv] that values are properly initialized.
|
||||
/// As a consequence, calling e.g. `mem::uninitialized::<bool>()` causes immediate
|
||||
/// undefined behavior for returning a `bool` that is not definitely either `true`
|
||||
/// or `false`. Worse, truly uninitialized memory like what gets returned here
|
||||
@ -521,6 +523,8 @@ pub unsafe fn zeroed<T>() -> T {
|
||||
/// until they are, it is advisable to avoid them.)
|
||||
///
|
||||
/// [`MaybeUninit<T>`]: union.MaybeUninit.html
|
||||
/// [uninit]: union.MaybeUninit.html#method.uninit
|
||||
/// [assume_init]: union.MaybeUninit.html#method.assume_init
|
||||
/// [inv]: union.MaybeUninit.html#initialization-invariant
|
||||
#[inline]
|
||||
#[rustc_deprecated(since = "1.39.0", reason = "use `mem::MaybeUninit` instead")]
|
||||
|
Loading…
Reference in New Issue
Block a user