From fbaff474f6da603b50f16adeda15cee873ad6a8a Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Tue, 8 Oct 2019 20:08:32 -0400 Subject: [PATCH] fix: correct old rust builds --- src/buffer/mod.rs | 14 ++++++++------ src/d2s.rs | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/buffer/mod.rs b/src/buffer/mod.rs index 579e36d..fee80be 100644 --- a/src/buffer/mod.rs +++ b/src/buffer/mod.rs @@ -35,13 +35,15 @@ impl Buffer { #[inline] #[cfg_attr(feature = "no-panic", no_panic)] pub fn new() -> Self { + // assume_init is safe here, since this is an array of MaybeUninit, which does not need + // to be initialized. + #[cfg(maybe_uninit)] + let bytes = unsafe { MaybeUninit::uninit().assume_init() }; + #[cfg(not(maybe_uninit))] + let bytes = unsafe { mem::uninitialized() }; + Buffer { - // assume_init is safe here, since this is an array of MaybeUninit, which does not need - // to be initialized. - #[cfg(maybe_uninit)] - bytes: unsafe { MaybeUninit::uninit().assume_init() }, - #[cfg(not(maybe_uninit))] - bytes: unsafe { mem::uninitialized() }, + bytes: bytes, } } diff --git a/src/d2s.rs b/src/d2s.rs index 9c4243b..375e3cd 100644 --- a/src/d2s.rs +++ b/src/d2s.rs @@ -221,11 +221,11 @@ pub fn d2d(ieee_mantissa: u64, ieee_exponent: u32) -> FloatingDecimal64 { #[cfg(maybe_uninit)] { vp_uninit.as_mut_ptr() }, #[cfg(not(maybe_uninit))] - { &mut vp as *mut u64 }, + { &mut vp }, #[cfg(maybe_uninit)] { vm_uninit.as_mut_ptr() }, #[cfg(not(maybe_uninit))] - { &mut vm as *mut u64 }, + { &mut vm }, mm_shift, ); #[cfg(maybe_uninit)] @@ -272,11 +272,11 @@ pub fn d2d(ieee_mantissa: u64, ieee_exponent: u32) -> FloatingDecimal64 { #[cfg(maybe_uninit)] { vp_uninit.as_mut_ptr() }, #[cfg(not(maybe_uninit))] - { &mut vp as *mut u64 }, + { &mut vp }, #[cfg(maybe_uninit)] { vm_uninit.as_mut_ptr() }, #[cfg(not(maybe_uninit))] - { &mut vm as *mut u64 }, + { &mut vm }, mm_shift, ); #[cfg(maybe_uninit)]