From e1875742d024c9ac52889d26881ca39a2a14cd8e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 5 Aug 2019 20:13:59 +0200 Subject: [PATCH] assume_init: warn about valid != safe --- src/libcore/mem/maybe_uninit.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/mem/maybe_uninit.rs b/src/libcore/mem/maybe_uninit.rs index 64fdf504369f..20367f724b6f 100644 --- a/src/libcore/mem/maybe_uninit.rs +++ b/src/libcore/mem/maybe_uninit.rs @@ -402,6 +402,13 @@ impl MaybeUninit { /// /// [inv]: #initialization-invariant /// + /// On top of that, remember that most types have additional invariants beyond merely + /// being considered initialized at the type level. For example, a `1`-initialized [`Vec`] + /// is considered initialized because the only requirement the compiler knows about it + /// is that the data pointer must be non-null. Creating such a `Vec` does not cause + /// *immediate* undefined behavior, but will cause undefined behavior with most + /// safe operations (including dropping it). + /// /// # Examples /// /// Correct usage of this method: