diff options
| author | Artyom Pavlov <newpavlov@gmail.com> | 2018-10-13 22:01:59 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-13 22:01:59 +0000 |
| commit | 4210ccad140790df7b4fa0438637d39cad3701b9 (patch) | |
| tree | 2aaef749a2ec42f62357ff0128da290eb99fad1b | |
| parent | 8f19cadf9508963ca3af9c9b184b65f4e0ff70e4 (diff) | |
| download | rust-4210ccad140790df7b4fa0438637d39cad3701b9.tar.gz rust-4210ccad140790df7b4fa0438637d39cad3701b9.zip | |
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.
| -rw-r--r-- | src/libcore/mem.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 27ee9556bd0..06febf33c61 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -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. |
