Improve #Safety of core::ptr::drop_in_place

Added missing conditions:
- Valid for writes
- Valid for destructing
This commit is contained in:
Amos Onn 2020-02-15 00:34:15 +01:00
parent 40ca167944
commit 943e65396d

View file

@ -119,10 +119,13 @@ mod mut_ptr;
///
/// Behavior is undefined if any of the following conditions are violated:
///
/// * `to_drop` must be [valid] for reads.
/// * `to_drop` must be [valid] for both reads and writes.
///
/// * `to_drop` must be properly aligned.
///
/// * The value `to_drop` points to must be valid for dropping, which may mean it must uphold
/// additional invariants - this is type-dependent.
///
/// Additionally, if `T` is not [`Copy`], using the pointed-to value after
/// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop =
/// foo` counts as a use because it will cause the value to be dropped