Skip to content

Commit e187574

Browse files
committed
assume_init: warn about valid != safe
1 parent 4be0675 commit e187574

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libcore/mem/maybe_uninit.rs

+7
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,13 @@ impl<T> MaybeUninit<T> {
402402
///
403403
/// [inv]: #initialization-invariant
404404
///
405+
/// On top of that, remember that most types have additional invariants beyond merely
406+
/// being considered initialized at the type level. For example, a `1`-initialized [`Vec<T>`]
407+
/// is considered initialized because the only requirement the compiler knows about it
408+
/// is that the data pointer must be non-null. Creating such a `Vec<T>` does not cause
409+
/// *immediate* undefined behavior, but will cause undefined behavior with most
410+
/// safe operations (including dropping it).
411+
///
405412
/// # Examples
406413
///
407414
/// Correct usage of this method:

0 commit comments

Comments
 (0)