From 23d4d77a11180872c2e554bc1901026ff445329c Mon Sep 17 00:00:00 2001
From: Manish Goregaokar <manishsmail@gmail.com>
Date: Thu, 2 Mar 2023 16:48:02 -0800
Subject: [PATCH 1/2] Clarify drop_in_place safety

---
 library/core/src/ptr/mod.rs | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 1ad9af1549a47..842f6e349e2b8 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -430,6 +430,10 @@ mod mut_ptr;
 /// done automatically by the compiler. This means the fields of packed structs
 /// are not dropped in-place.
 ///
+/// [`drop_in_place()`] does not modify the pointed-to value beyond any changes
+/// performed by [`Drop::drop()`]. As far as the compiler is concerned, the value
+/// will still contain a valid bit pattern for type `T`.
+///
 /// [`ptr::read`]: self::read
 /// [`ptr::read_unaligned`]: self::read_unaligned
 /// [pinned]: crate::pin
@@ -446,10 +450,15 @@ mod mut_ptr;
 ///   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 =
+/// calling `drop_in_place` may cause undefined behavior. Note that `*to_drop =
 /// foo` counts as a use because it will cause the value to be dropped
 /// again. [`write()`] can be used to overwrite data without causing it to be
-/// dropped.
+/// dropped. Read operations may be UB based on library invariants of that type,
+/// for example reading the value pointed to by a dropped `Box<T>` is a use-after-free.
+///
+/// Having an `&` or `&mut` reference to the pointed-to value after calling [`drop_in_place()`]
+/// is still sound as long as it is not read from (in which case the soundness of the operation
+/// depends on the specific type).
 ///
 /// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
 ///

From f6747b02e38bd7cdf9d98cbeeba318e76ec096ba Mon Sep 17 00:00:00 2001
From: Manish Goregaokar <manishsmail@gmail.com>
Date: Sat, 4 Mar 2023 11:11:29 -0800
Subject: [PATCH 2/2] Remove note on references

---
 library/core/src/ptr/mod.rs | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
index 842f6e349e2b8..441d4fd31cb61 100644
--- a/library/core/src/ptr/mod.rs
+++ b/library/core/src/ptr/mod.rs
@@ -456,10 +456,6 @@ mod mut_ptr;
 /// dropped. Read operations may be UB based on library invariants of that type,
 /// for example reading the value pointed to by a dropped `Box<T>` is a use-after-free.
 ///
-/// Having an `&` or `&mut` reference to the pointed-to value after calling [`drop_in_place()`]
-/// is still sound as long as it is not read from (in which case the soundness of the operation
-/// depends on the specific type).
-///
 /// Note that even if `T` has size `0`, the pointer must be non-null and properly aligned.
 ///
 /// [valid]: self#safety