File tree Expand file tree Collapse file tree 3 files changed +3
-10
lines changed
Expand file tree Collapse file tree 3 files changed +3
-10
lines changed Original file line number Diff line number Diff line change 109109#![ feature( pattern) ]
110110#![ feature( ptr_internals) ]
111111#![ feature( ptr_offset_from) ]
112+ #![ feature( raw_ref_op) ]
112113#![ feature( rustc_attrs) ]
113114#![ feature( receiver_trait) ]
114115#![ feature( min_specialization) ]
Original file line number Diff line number Diff line change @@ -591,17 +591,13 @@ impl<T: ?Sized> Rc<T> {
591591 #[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
592592 pub fn as_ptr ( this : & Self ) -> * const T {
593593 let ptr: * mut RcBox < T > = NonNull :: as_ptr ( this. ptr ) ;
594- let fake_ptr = ptr as * mut T ;
595594
596595 // SAFETY: This cannot go through Deref::deref.
597596 // Instead, we manually offset the pointer rather than manifesting a reference.
598597 // This is so that the returned pointer retains the same provenance as our pointer.
599598 // This is required so that e.g. `get_mut` can write through the pointer
600599 // after the Rc is recovered through `from_raw`.
601- unsafe {
602- let offset = data_offset ( & ( * ptr) . value ) ;
603- set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . offset ( offset) )
604- }
600+ unsafe { & raw const ( * ptr) . value }
605601 }
606602
607603 /// Constructs an `Rc<T>` from a raw pointer.
Original file line number Diff line number Diff line change @@ -590,17 +590,13 @@ impl<T: ?Sized> Arc<T> {
590590 #[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
591591 pub fn as_ptr ( this : & Self ) -> * const T {
592592 let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( this. ptr ) ;
593- let fake_ptr = ptr as * mut T ;
594593
595594 // SAFETY: This cannot go through Deref::deref.
596595 // Instead, we manually offset the pointer rather than manifesting a reference.
597596 // This is so that the returned pointer retains the same provenance as our pointer.
598597 // This is required so that e.g. `get_mut` can write through the pointer
599598 // after the Arc is recovered through `from_raw`.
600- unsafe {
601- let offset = data_offset ( & ( * ptr) . data ) ;
602- set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . offset ( offset) )
603- }
599+ unsafe { & raw const ( * ptr) . data }
604600 }
605601
606602 /// Constructs an `Arc<T>` from a raw pointer.
You can’t perform that action at this time.
0 commit comments