From fb27373551a55e7a4f6b829b83f6601bef0a7ac5 Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Wed, 17 Aug 2022 12:48:14 +0200 Subject: [PATCH] Fixed CI issues --- src/error.rs | 9 ++------- src/features/impl_alloc.rs | 2 +- src/features/serde/de_borrowed.rs | 2 +- src/features/serde/de_owned.rs | 2 +- src/features/serde/mod.rs | 7 +++---- src/features/serde/ser.rs | 4 ++-- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/error.rs b/src/error.rs index 148ddf84..0046f417 100644 --- a/src/error.rs +++ b/src/error.rs @@ -197,12 +197,14 @@ pub enum OutOfMemory { Alloc(AllocError), } +#[cfg(feature = "alloc")] impl From for DecodeError { fn from(e: TryReserveError) -> Self { Self::OutOfMemory(OutOfMemory::TryReserve(e)) } } +#[cfg(feature = "alloc")] impl From for EncodeError { fn from(e: TryReserveError) -> Self { Self::OutOfMemory(OutOfMemory::TryReserve(e)) @@ -223,13 +225,6 @@ impl From for EncodeError { } } -#[cfg(all(feature = "alloc", feature = "unstable-strict-oom-checks"))] -impl From for DecodeError { - fn from(e: AllocError) -> Self { - Self::OutOfMemory(OutOfMemory::Alloc(e)) - } -} - impl core::fmt::Display for DecodeError { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { // TODO: Improve this? diff --git a/src/features/impl_alloc.rs b/src/features/impl_alloc.rs index 2d8800f1..b14c2160 100644 --- a/src/features/impl_alloc.rs +++ b/src/features/impl_alloc.rs @@ -437,7 +437,7 @@ where T: Decode, { fn decode(decoder: &mut D) -> Result { - let len = decode_slice_len(decoder)?; + let len = crate::de::decode_slice_len(decoder)?; decoder.claim_container_read::(len)?; unsafe { diff --git a/src/features/serde/de_borrowed.rs b/src/features/serde/de_borrowed.rs index d70d2c3e..fbda60ef 100644 --- a/src/features/serde/de_borrowed.rs +++ b/src/features/serde/de_borrowed.rs @@ -403,7 +403,7 @@ impl<'de, 'a, DE: BorrowDecoder<'de>> EnumAccess<'de> for SerdeDecoder<'a, 'de, V: DeserializeSeed<'de>, { let idx = u32::decode(&mut self.de)?; - let val = seed.deserialize(idx.into_deserializer())?; + let val = seed.deserialize(serde::de::value::U32Deserializer::::new(idx))?; Ok((val, self)) } } diff --git a/src/features/serde/de_owned.rs b/src/features/serde/de_owned.rs index 9a3ba780..d9397b68 100644 --- a/src/features/serde/de_owned.rs +++ b/src/features/serde/de_owned.rs @@ -449,7 +449,7 @@ impl<'de, 'a, DE: Decoder> EnumAccess<'de> for SerdeDecoder<'a, DE> { V: DeserializeSeed<'de>, { let idx = u32::decode(&mut self.de)?; - let val = seed.deserialize(idx.into_deserializer())?; + let val = seed.deserialize(serde::de::value::U32Deserializer::::new(idx))?; Ok((val, self)) } } diff --git a/src/features/serde/mod.rs b/src/features/serde/mod.rs index fc3952fb..f418380e 100644 --- a/src/features/serde/mod.rs +++ b/src/features/serde/mod.rs @@ -142,10 +142,9 @@ pub enum EncodeError { CustomError, } -#[allow(clippy::from_over_into)] -impl Into for EncodeError { - fn into(self) -> crate::error::EncodeError { - crate::error::EncodeError::Serde(self) +impl From for crate::error::EncodeError { + fn from(val: EncodeError) -> Self { + crate::error::EncodeError::Serde(val) } } diff --git a/src/features/serde/ser.rs b/src/features/serde/ser.rs index feede35c..7c8e62b9 100644 --- a/src/features/serde/ser.rs +++ b/src/features/serde/ser.rs @@ -224,7 +224,7 @@ where } fn serialize_seq(mut self, len: Option) -> Result { - let len = len.ok_or_else(|| SerdeEncodeError::SequenceMustHaveLength.into())?; + let len = len.ok_or(EncodeError::Serde(SerdeEncodeError::SequenceMustHaveLength))?; len.encode(&mut self.enc)?; Ok(Compound { enc: self.enc }) } @@ -253,7 +253,7 @@ where } fn serialize_map(mut self, len: Option) -> Result { - let len = len.ok_or_else(|| SerdeEncodeError::SequenceMustHaveLength.into())?; + let len = len.ok_or(EncodeError::Serde(SerdeEncodeError::SequenceMustHaveLength))?; len.encode(&mut self.enc)?; Ok(Compound { enc: self.enc }) }