Use read_unaligned instead of read in transmute_copy
Closes: #55044 This change could result in performance regression on non-x86 platforms. Alternative would be to update `transmute_copy` with alignment requirements.
This commit is contained in:
parent
8f19cadf95
commit
4210ccad14
@ -818,7 +818,7 @@ pub fn drop<T>(_x: T) { }
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
|
||||
ptr::read(src as *const T as *const U)
|
||||
ptr::read_unaligned(src as *const T as *const U)
|
||||
}
|
||||
|
||||
/// Opaque type representing the discriminant of an enum.
|
||||
|
Loading…
Reference in New Issue
Block a user