Skip to content

Commit

Permalink
Improve #Safety of core::ptr::drop_in_place
Browse files Browse the repository at this point in the history
Added missing conditions:
- Valid for writes
- Valid for destructing
  • Loading branch information
amosonn committed Feb 16, 2020
1 parent 40ca167 commit 943e653
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libcore/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 943e653

Please sign in to comment.