Improve #Safety of core::ptr::drop_in_place
Added missing conditions: - Valid for writes - Valid for destructing
This commit is contained in:
parent
40ca167944
commit
943e65396d
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue