about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmos Onn <amosonn@gmail.com>2020-02-15 00:34:15 +0100
committerAmos Onn <amosonn@gmail.com>2020-02-16 13:12:34 +0100
commit943e65396d7bc7b91bcc30407d323d06f4b20a22 (patch)
tree20f6a6ce98b0d8c23a2e69b2803802308dd50910
parent40ca16794456e9b1520bba6d887a176395f127f0 (diff)
downloadrust-943e65396d7bc7b91bcc30407d323d06f4b20a22.tar.gz
rust-943e65396d7bc7b91bcc30407d323d06f4b20a22.zip
Improve #Safety of core::ptr::drop_in_place
Added missing conditions:
- Valid for writes
- Valid for destructing
-rw-r--r--src/libcore/ptr/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs
index 7fb2d4f0399..88b490a25d5 100644
--- a/src/libcore/ptr/mod.rs
+++ b/src/libcore/ptr/mod.rs
@@ -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