From 4210ccad140790df7b4fa0438637d39cad3701b9 Mon Sep 17 00:00:00 2001 From: Artyom Pavlov Date: Sat, 13 Oct 2018 22:01:59 +0000 Subject: [PATCH] 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. --- src/libcore/mem.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(_x: T) { } #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn transmute_copy(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.