about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_data_structures/src/tagged_ptr/copy.rs24
-rw-r--r--compiler/rustc_data_structures/src/tagged_ptr/drop.rs7
2 files changed, 11 insertions, 20 deletions
diff --git a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs
index 235c92da699..644f1415e73 100644
--- a/compiler/rustc_data_structures/src/tagged_ptr/copy.rs
+++ b/compiler/rustc_data_structures/src/tagged_ptr/copy.rs
@@ -115,19 +115,6 @@ where
         unsafe { P::from_ptr(self.pointer_raw()) }
     }
 
-    pub fn pointer_ref(&self) -> &P::Target {
-        // SAFETY: pointer_raw returns the original pointer
-        unsafe { self.pointer_raw().as_ref() }
-    }
-
-    pub fn pointer_mut(&mut self) -> &mut P::Target
-    where
-        P: DerefMut,
-    {
-        // SAFETY: pointer_raw returns the original pointer
-        unsafe { self.pointer_raw().as_mut() }
-    }
-
     #[inline]
     pub fn tag(&self) -> T {
         unsafe { T::from_usize(self.packed.addr().get() >> Self::TAG_BIT_SHIFT) }
@@ -147,7 +134,10 @@ where
     type Target = P::Target;
 
     fn deref(&self) -> &Self::Target {
-        self.pointer_ref()
+        // Safety:
+        // `pointer_raw` returns the original pointer from `P::into_ptr` which,
+        // by the `Pointer`'s contract, must be valid.
+        unsafe { self.pointer_raw().as_ref() }
     }
 }
 
@@ -157,7 +147,11 @@ where
     T: Tag,
 {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        self.pointer_mut()
+        // Safety:
+        // `pointer_raw` returns the original pointer from `P::into_ptr` which,
+        // by the `Pointer`'s contract, must be valid for writes if
+        // `P: DerefMut`.
+        unsafe { self.pointer_raw().as_mut() }
     }
 }
 
diff --git a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs
index d3fba0c30a9..6e51916838f 100644
--- a/compiler/rustc_data_structures/src/tagged_ptr/drop.rs
+++ b/compiler/rustc_data_structures/src/tagged_ptr/drop.rs
@@ -41,9 +41,6 @@ where
         TaggedPtr { raw: CopyTaggedPtr::new(pointer, tag) }
     }
 
-    pub fn pointer_ref(&self) -> &P::Target {
-        self.raw.pointer_ref()
-    }
     pub fn tag(&self) -> T {
         self.raw.tag()
     }
@@ -56,7 +53,7 @@ where
 {
     type Target = P::Target;
     fn deref(&self) -> &Self::Target {
-        self.raw.pointer_ref()
+        self.raw.deref()
     }
 }
 
@@ -66,7 +63,7 @@ where
     T: Tag,
 {
     fn deref_mut(&mut self) -> &mut Self::Target {
-        self.raw.pointer_mut()
+        self.raw.deref_mut()
     }
 }