diff --git a/src/features/impl_alloc.rs b/src/features/impl_alloc.rs index 2a37ce72..3d65671d 100644 --- a/src/features/impl_alloc.rs +++ b/src/features/impl_alloc.rs @@ -266,7 +266,7 @@ where if unty::type_equal::() { decoder.claim_container_read::(len)?; // optimize for reading u8 vecs - let mut vec = alloc::vec![0u8; len]; + let mut vec = alloc::vec::from_elem(0u8, len); decoder.reader().read(&mut vec)?; // Safety: Vec is Vec Ok(unsafe { core::mem::transmute(vec) }) @@ -630,6 +630,7 @@ where } } +#[cfg(not(feature = "unstable-strict-oom-checks"))] /// A drop guard that will trigger when an item fails to decode. /// If an item at index n fails to decode, we have to properly drop the 0..(n-1) values that have been read. struct DropGuard<'a, T> { @@ -637,6 +638,7 @@ struct DropGuard<'a, T> { idx: usize, } +#[cfg(not(feature = "unstable-strict-oom-checks"))] impl<'a, T> Drop for DropGuard<'a, T> { fn drop(&mut self) { unsafe { diff --git a/src/lib.rs b/src/lib.rs index 2ac669cb..db8b59a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -100,7 +100,6 @@ pub mod de; pub mod enc; pub mod error; -pub use atomic::*; pub use de::{BorrowDecode, Decode}; pub use enc::Encode; diff --git a/src/varint/decode_unsigned.rs b/src/varint/decode_unsigned.rs index de0f0b95..ea2091d6 100644 --- a/src/varint/decode_unsigned.rs +++ b/src/varint/decode_unsigned.rs @@ -1,11 +1,10 @@ -use core::{convert::TryInto, u32}; - use super::{SINGLE_BYTE_MAX, U128_BYTE, U16_BYTE, U32_BYTE, U64_BYTE}; use crate::{ config::Endianness, de::read::Reader, error::{DecodeError, IntegerType}, }; +use core::u32; #[inline(never)] #[cold]