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 109
109
#![ feature( pattern) ]
110
110
#![ feature( ptr_internals) ]
111
111
#![ feature( ptr_offset_from) ]
112
+ #![ feature( raw_ref_op) ]
112
113
#![ feature( rustc_attrs) ]
113
114
#![ feature( receiver_trait) ]
114
115
#![ feature( min_specialization) ]
Original file line number Diff line number Diff line change @@ -591,17 +591,13 @@ impl<T: ?Sized> Rc<T> {
591
591
#[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
592
592
pub fn as_ptr ( this : & Self ) -> * const T {
593
593
let ptr: * mut RcBox < T > = NonNull :: as_ptr ( this. ptr ) ;
594
- let fake_ptr = ptr as * mut T ;
595
594
596
595
// SAFETY: This cannot go through Deref::deref.
597
596
// Instead, we manually offset the pointer rather than manifesting a reference.
598
597
// This is so that the returned pointer retains the same provenance as our pointer.
599
598
// This is required so that e.g. `get_mut` can write through the pointer
600
599
// 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 }
605
601
}
606
602
607
603
/// 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> {
590
590
#[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
591
591
pub fn as_ptr ( this : & Self ) -> * const T {
592
592
let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( this. ptr ) ;
593
- let fake_ptr = ptr as * mut T ;
594
593
595
594
// SAFETY: This cannot go through Deref::deref.
596
595
// Instead, we manually offset the pointer rather than manifesting a reference.
597
596
// This is so that the returned pointer retains the same provenance as our pointer.
598
597
// This is required so that e.g. `get_mut` can write through the pointer
599
598
// 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 }
604
600
}
605
601
606
602
/// Constructs an `Arc<T>` from a raw pointer.
You can’t perform that action at this time.
0 commit comments