File tree 2 files changed +4
-6
lines changed
2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -1703,7 +1703,6 @@ impl<T> Weak<T> {
1703
1703
#[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
1704
1704
pub fn as_ptr ( & self ) -> * const T {
1705
1705
let ptr: * mut RcBox < T > = NonNull :: as_ptr ( self . ptr ) ;
1706
- let fake_ptr = ptr as * mut T ;
1707
1706
1708
1707
// SAFETY: we must offset the pointer manually, and said pointer may be
1709
1708
// a dangling weak (usize::MAX). data_offset is safe to call, because we
@@ -1712,8 +1711,8 @@ impl<T> Weak<T> {
1712
1711
// is used so that we can use the same code path for the non-dangling
1713
1712
// unsized case and the potentially dangling sized case.
1714
1713
unsafe {
1715
- let offset = data_offset ( fake_ptr ) ;
1716
- set_data_ptr ( fake_ptr , ( ptr as * mut u8 ) . wrapping_offset ( offset) )
1714
+ let offset = data_offset ( ptr as * mut T ) ;
1715
+ set_data_ptr ( ptr as * mut T , ( ptr as * mut u8 ) . wrapping_offset ( offset) )
1717
1716
}
1718
1717
}
1719
1718
Original file line number Diff line number Diff line change @@ -1471,7 +1471,6 @@ impl<T> Weak<T> {
1471
1471
#[ stable( feature = "weak_into_raw" , since = "1.45.0" ) ]
1472
1472
pub fn as_ptr ( & self ) -> * const T {
1473
1473
let ptr: * mut ArcInner < T > = NonNull :: as_ptr ( self . ptr ) ;
1474
- let fake_ptr = ptr as * mut T ;
1475
1474
1476
1475
// SAFETY: we must offset the pointer manually, and said pointer may be
1477
1476
// a dangling weak (usize::MAX). data_offset is safe to call, because we
@@ -1480,8 +1479,8 @@ impl<T> Weak<T> {
1480
1479
// is used so that we can use the same code path for the non-dangling
1481
1480
// unsized case and the potentially dangling sized case.
1482
1481
unsafe {
1483
- let offset = data_offset ( fake_ptr ) ;
1484
- set_data_ptr ( fake_ptr , ( ptr as * mut u8 ) . wrapping_offset ( offset) )
1482
+ let offset = data_offset ( ptr as * mut T ) ;
1483
+ set_data_ptr ( ptr as * mut T , ( ptr as * mut u8 ) . wrapping_offset ( offset) )
1485
1484
}
1486
1485
}
1487
1486
You can’t perform that action at this time.
0 commit comments