From 36bb5e8a4247888c7e1ce5a06ba3aaf5dc9cafd5 Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Tue, 21 Jul 2020 22:44:25 +0200 Subject: [PATCH 1/2] Clarify the doc for MaybeUninit::zeroed on incorrect use --- library/core/src/mem/maybe_uninit.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 7732525a0fc28..b76ad7ceec948 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -336,8 +336,9 @@ impl MaybeUninit { /// assert_eq!(x, (0, false)); /// ``` /// - /// *Incorrect* usage of this function: initializing a struct with zero, where some fields - /// cannot hold 0 as a valid value. + /// *Incorrect* usage of this function: assuming zero filled memory is initialized, + /// where some fields cannot hold 0 as a valid value, without overwriting with a + /// valid bit-pattern. /// /// ```rust,no_run /// use std::mem::MaybeUninit; From 54eb3768e0077bc18152b5fc3d19824cde69c8ce Mon Sep 17 00:00:00 2001 From: Alexis Bourget Date: Sat, 1 Aug 2020 19:28:19 +0200 Subject: [PATCH 2/2] Reword incorrect use of zeroed() --- library/core/src/mem/maybe_uninit.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index b76ad7ceec948..cf721b01ce3c6 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -336,9 +336,8 @@ impl MaybeUninit { /// assert_eq!(x, (0, false)); /// ``` /// - /// *Incorrect* usage of this function: assuming zero filled memory is initialized, - /// where some fields cannot hold 0 as a valid value, without overwriting with a - /// valid bit-pattern. + /// *Incorrect* usage of this function: calling `x.zeroed().assume_init()` + /// when `0` is not a valid bit-pattern for the type: /// /// ```rust,no_run /// use std::mem::MaybeUninit;