diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 9cf42eff219ba..d8d51f53377f7 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1509,7 +1509,9 @@ impl UnsafeCell { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub const fn get(&self) -> *mut T { - &self.value as *const T as *mut T + // We can just cast the pointer from `UnsafeCell` to `T` because of + // #[repr(transparent)] + self as *const UnsafeCell as *const T as *mut T } }