diff options
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/rc.rs | 5 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 29e0979b0ed..4d77779b209 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1703,7 +1703,6 @@ impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr); - let fake_ptr = ptr as *mut T; // SAFETY: we must offset the pointer manually, and said pointer may be // a dangling weak (usize::MAX). data_offset is safe to call, because we @@ -1712,8 +1711,8 @@ impl<T> Weak<T> { // is used so that we can use the same code path for the non-dangling // unsized case and the potentially dangling sized case. unsafe { - let offset = data_offset(fake_ptr); - set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset)) + let offset = data_offset(ptr as *mut T); + set_data_ptr(ptr as *mut T, (ptr as *mut u8).wrapping_offset(offset)) } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 005821980fe..160abe7210c 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -1471,7 +1471,6 @@ impl<T> Weak<T> { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { let ptr: *mut ArcInner<T> = NonNull::as_ptr(self.ptr); - let fake_ptr = ptr as *mut T; // SAFETY: we must offset the pointer manually, and said pointer may be // a dangling weak (usize::MAX). data_offset is safe to call, because we @@ -1480,8 +1479,8 @@ impl<T> Weak<T> { // is used so that we can use the same code path for the non-dangling // unsized case and the potentially dangling sized case. unsafe { - let offset = data_offset(fake_ptr); - set_data_ptr(fake_ptr, (ptr as *mut u8).wrapping_offset(offset)) + let offset = data_offset(ptr as *mut T); + set_data_ptr(ptr as *mut T, (ptr as *mut u8).wrapping_offset(offset)) } } |
