library: use addr_of!
This commit is contained in:
parent
8f359beca4
commit
ff187a92d8
35 changed files with 83 additions and 74 deletions
|
@ -176,7 +176,7 @@ impl<T: ?Sized> ThinBox<T> {
|
|||
|
||||
fn with_header(&self) -> &WithHeader<<T as Pointee>::Metadata> {
|
||||
// SAFETY: both types are transparent to `NonNull<u8>`
|
||||
unsafe { &*((&self.ptr) as *const WithOpaqueHeader as *const WithHeader<_>) }
|
||||
unsafe { &*(core::ptr::addr_of!(self.ptr) as *const WithHeader<_>) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1969,7 +1969,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
|
|||
|
||||
// Copy value as bytes
|
||||
ptr::copy_nonoverlapping(
|
||||
&*src as *const T as *const u8,
|
||||
core::ptr::addr_of!(*src) as *const u8,
|
||||
ptr::addr_of_mut!((*ptr).value) as *mut u8,
|
||||
value_size,
|
||||
);
|
||||
|
@ -2440,7 +2440,7 @@ impl<T: ?Sized + fmt::Debug, A: Allocator> fmt::Debug for Rc<T, A> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized, A: Allocator> fmt::Pointer for Rc<T, A> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Pointer::fmt(&(&**self as *const T), f)
|
||||
fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1914,7 +1914,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
|
|||
|
||||
// Copy value as bytes
|
||||
ptr::copy_nonoverlapping(
|
||||
&*src as *const T as *const u8,
|
||||
core::ptr::addr_of!(*src) as *const u8,
|
||||
ptr::addr_of_mut!((*ptr).data) as *mut u8,
|
||||
value_size,
|
||||
);
|
||||
|
@ -3265,7 +3265,7 @@ impl<T: ?Sized + fmt::Debug, A: Allocator> fmt::Debug for Arc<T, A> {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized, A: Allocator> fmt::Pointer for Arc<T, A> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Pointer::fmt(&(&**self as *const T), f)
|
||||
fmt::Pointer::fmt(&core::ptr::addr_of!(**self), f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue