diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-13 20:35:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-13 20:35:34 +0100 |
| commit | 83536a5c82fae9278831cf74e82d9d8cdaf2d455 (patch) | |
| tree | 5d046fb139ce9065272e3215d75fe9e5add0091d | |
| parent | 88e702a6ec5e166f20dfc51eaa4b85fc4a045d6b (diff) | |
| parent | 216b9ae8780655c001b7401b630a046633e1b3c6 (diff) | |
Rollup merge of #67274 - RalfJung:uninit, r=Centril
be explicit that mem::uninitialized is the same as MaybeUninit::uninit().assume_init() Cc @Centril @nikomatsakis
| -rw-r--r-- | src/libcore/mem/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index bba441464ff..ec926aa6c23 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -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")] |
