1313//! The tag must implement the `Tag` trait. We assert that the tag and `Pointer`
1414//! are compatible at compile time.
1515
16- use std:: mem:: ManuallyDrop ;
1716use std:: ops:: Deref ;
1817use std:: ptr:: NonNull ;
1918use std:: rc:: Rc ;
@@ -81,16 +80,6 @@ pub unsafe trait Pointer: Deref {
8180 /// This acts as `ptr::read` semantically, it should not be called more than
8281 /// once on non-`Copy` `Pointer`s.
8382 unsafe fn from_ptr ( ptr : NonNull < Self :: Target > ) -> Self ;
84-
85- /// This provides a reference to the `Pointer` itself, rather than the
86- /// `Deref::Target`. It is used for cases where we want to call methods that
87- /// may be implement differently for the Pointer than the Pointee (e.g.,
88- /// `Rc::clone` vs cloning the inner value).
89- ///
90- /// # Safety
91- ///
92- /// The passed `ptr` must be returned from `into_usize`.
93- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( ptr : NonNull < Self :: Target > , f : F ) -> R ;
9483}
9584
9685/// This describes tags that the `TaggedPtr` struct can hold.
@@ -124,11 +113,6 @@ unsafe impl<T: ?Sized + Aligned> Pointer for Box<T> {
124113 unsafe fn from_ptr ( ptr : NonNull < T > ) -> Self {
125114 Box :: from_raw ( ptr. as_ptr ( ) )
126115 }
127-
128- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( ptr : NonNull < T > , f : F ) -> R {
129- let raw = ManuallyDrop :: new ( Self :: from_ptr ( ptr) ) ;
130- f ( & raw )
131- }
132116}
133117
134118unsafe impl < T : ?Sized + Aligned > Pointer for Rc < T > {
@@ -143,11 +127,6 @@ unsafe impl<T: ?Sized + Aligned> Pointer for Rc<T> {
143127 unsafe fn from_ptr ( ptr : NonNull < T > ) -> Self {
144128 Rc :: from_raw ( ptr. as_ptr ( ) )
145129 }
146-
147- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( ptr : NonNull < T > , f : F ) -> R {
148- let raw = ManuallyDrop :: new ( Self :: from_ptr ( ptr) ) ;
149- f ( & raw )
150- }
151130}
152131
153132unsafe impl < T : ?Sized + Aligned > Pointer for Arc < T > {
@@ -162,11 +141,6 @@ unsafe impl<T: ?Sized + Aligned> Pointer for Arc<T> {
162141 unsafe fn from_ptr ( ptr : NonNull < T > ) -> Self {
163142 Arc :: from_raw ( ptr. as_ptr ( ) )
164143 }
165-
166- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( ptr : NonNull < T > , f : F ) -> R {
167- let raw = ManuallyDrop :: new ( Self :: from_ptr ( ptr) ) ;
168- f ( & raw )
169- }
170144}
171145
172146unsafe impl < ' a , T : ' a + ?Sized + Aligned > Pointer for & ' a T {
@@ -181,10 +155,6 @@ unsafe impl<'a, T: 'a + ?Sized + Aligned> Pointer for &'a T {
181155 unsafe fn from_ptr ( ptr : NonNull < T > ) -> Self {
182156 ptr. as_ref ( )
183157 }
184-
185- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( ptr : NonNull < T > , f : F ) -> R {
186- f ( & ptr. as_ref ( ) )
187- }
188158}
189159
190160unsafe impl < ' a , T : ' a + ?Sized + Aligned > Pointer for & ' a mut T {
@@ -199,10 +169,6 @@ unsafe impl<'a, T: 'a + ?Sized + Aligned> Pointer for &'a mut T {
199169 unsafe fn from_ptr ( mut ptr : NonNull < T > ) -> Self {
200170 ptr. as_mut ( )
201171 }
202-
203- unsafe fn with_ref < R , F : FnOnce ( & Self ) -> R > ( mut ptr : NonNull < T > , f : F ) -> R {
204- f ( & ptr. as_mut ( ) )
205- }
206172}
207173
208174/// Returns the number of bits available for use for tags in a pointer to `T`
0 commit comments