From 5e27ee76b652dc7fbe5da1d213580c9ada0d65e1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 10 Oct 2018 12:04:07 +0200 Subject: [PATCH] use MaybeUninit in core::ptr::swap_nonoverlapping_bytes Code by @japaric, I just split it into individual commits --- src/libcore/ptr.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 5032c112f7c..947b67e4e9a 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -389,8 +389,8 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { while i + block_size <= len { // Create some uninitialized memory as scratch space // Declaring `t` here avoids aligning the stack when this loop is unused - let mut t: Block = mem::uninitialized(); - let t = &mut t as *mut _ as *mut u8; + let mut t = mem::MaybeUninit::::uninitialized(); + let t = t.as_mut_ptr() as *mut u8; let x = x.add(i); let y = y.add(i); @@ -404,10 +404,10 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { if i < len { // Swap any remaining bytes - let mut t: UnalignedBlock = mem::uninitialized(); + let mut t = mem::MaybeUninit::::uninitialized(); let rem = len - i; - let t = &mut t as *mut _ as *mut u8; + let t = t.as_mut_ptr() as *mut u8; let x = x.add(i); let y = y.add(i);