about summary refs log tree commit diff
path: root/src/liballoc/rc.rs
diff options
context:
space:
mode:
authorCAD97 <cad97@cad97.com>2020-07-01 15:03:12 -0400
committerCAD97 <cad97@cad97.com>2020-07-01 15:06:07 -0400
commit98789ac75a15c78462ada2438881c8a4e4fda94a (patch)
tree183bd575c20041f15c7ee957d9cfa2f02e214be6 /src/liballoc/rc.rs
parentac40d1eff33cc6789d3c02f4a21477368574cf5e (diff)
downloadrust-98789ac75a15c78462ada2438881c8a4e4fda94a.tar.gz
rust-98789ac75a15c78462ada2438881c8a4e4fda94a.zip
Simplify Weak::as_ptr impl
Diffstat (limited to 'src/liballoc/rc.rs')
-rw-r--r--src/liballoc/rc.rs5
1 files changed, 2 insertions, 3 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))
         }
     }