Skip to content

Commit d72cb09

Browse files
authored
Rollup merge of #63298 - RalfJung:assume_init, r=Mark-Simulacrum,Centril
assume_init: warn about valid != safe We have this warning in the type-level docs, but it seems worth repeating it on the function.
2 parents fbf268b + 1821414 commit d72cb09

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Diff for: src/libcore/mem/maybe_uninit.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ use crate::mem::ManuallyDrop;
5151
///
5252
/// On top of that, remember that most types have additional invariants beyond merely
5353
/// being considered initialized at the type level. For example, a `1`-initialized [`Vec<T>`]
54-
/// is considered initialized because the only requirement the compiler knows about it
54+
/// is considered initialized (under the current implementation; this does not constitute
55+
/// a stable guarantee) because the only requirement the compiler knows about it
5556
/// is that the data pointer must be non-null. Creating such a `Vec<T>` does not cause
5657
/// *immediate* undefined behavior, but will cause undefined behavior with most
5758
/// safe operations (including dropping it).
@@ -402,6 +403,14 @@ impl<T> MaybeUninit<T> {
402403
///
403404
/// [inv]: #initialization-invariant
404405
///
406+
/// On top of that, remember that most types have additional invariants beyond merely
407+
/// being considered initialized at the type level. For example, a `1`-initialized [`Vec<T>`]
408+
/// is considered initialized (under the current implementation; this does not constitute
409+
/// a stable guarantee) because the only requirement the compiler knows about it
410+
/// is that the data pointer must be non-null. Creating such a `Vec<T>` does not cause
411+
/// *immediate* undefined behavior, but will cause undefined behavior with most
412+
/// safe operations (including dropping it).
413+
///
405414
/// # Examples
406415
///
407416
/// Correct usage of this method:

0 commit comments

Comments
 (0)