File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -571,9 +571,14 @@ impl<T: ?Sized> Rc<T> {
571571 /// ```
572572 #[ stable( feature = "rc_raw" , since = "1.17.0" ) ]
573573 pub fn into_raw ( this : Self ) -> * const T {
574- let ptr: * const T = & * this;
574+ let ptr: * mut RcBox < T > = NonNull :: as_ptr ( this. ptr ) ;
575+ let fake_ptr = ptr as * mut T ;
575576 mem:: forget ( this) ;
576- ptr
577+
578+ unsafe {
579+ let offset = data_offset ( & ( * ptr) . value ) ;
580+ set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . offset ( offset) )
581+ }
577582 }
578583
579584 /// Constructs an `Rc` from a raw pointer.
Original file line number Diff line number Diff line change @@ -551,9 +551,14 @@ impl<T: ?Sized> Arc<T> {
551551 /// ```
552552 #[ stable( feature = "rc_raw" , since = "1.17.0" ) ]
553553 pub fn into_raw ( this : Self ) -> * const T {
554- let ptr: * const T = & * this;
554+ let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( this. ptr ) ;
555+ let fake_ptr = ptr as * mut T ;
555556 mem:: forget ( this) ;
556- ptr
557+
558+ unsafe {
559+ let offset = data_offset ( & ( * ptr) . data ) ;
560+ set_data_ptr ( fake_ptr, ( ptr as * mut u8 ) . offset ( offset) )
561+ }
557562 }
558563
559564 /// Constructs an `Arc` from a raw pointer.
You can’t perform that action at this time.
0 commit comments