Skip to content

Commit

Permalink
Fixed CI issues
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorKoenders committed Aug 17, 2022
1 parent bc344d2 commit fb27373
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
9 changes: 2 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,14 @@ pub enum OutOfMemory {
Alloc(AllocError),
}

#[cfg(feature = "alloc")]
impl From<TryReserveError> for DecodeError {
fn from(e: TryReserveError) -> Self {
Self::OutOfMemory(OutOfMemory::TryReserve(e))
}
}

#[cfg(feature = "alloc")]
impl From<TryReserveError> for EncodeError {
fn from(e: TryReserveError) -> Self {
Self::OutOfMemory(OutOfMemory::TryReserve(e))
Expand All @@ -223,13 +225,6 @@ impl From<AllocError> for EncodeError {
}
}

#[cfg(all(feature = "alloc", feature = "unstable-strict-oom-checks"))]
impl From<AllocError> 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?
Expand Down
2 changes: 1 addition & 1 deletion src/features/impl_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ where
T: Decode,
{
fn decode<D: Decoder>(decoder: &mut D) -> Result<Self, DecodeError> {
let len = decode_slice_len(decoder)?;
let len = crate::de::decode_slice_len(decoder)?;
decoder.claim_container_read::<T>(len)?;

unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/features/serde/de_borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Self::Error>::new(idx))?;
Ok((val, self))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/features/serde/de_owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Self::Error>::new(idx))?;
Ok((val, self))
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/features/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ pub enum EncodeError {
CustomError,
}

#[allow(clippy::from_over_into)]
impl Into<crate::error::EncodeError> for EncodeError {
fn into(self) -> crate::error::EncodeError {
crate::error::EncodeError::Serde(self)
impl From<EncodeError> for crate::error::EncodeError {
fn from(val: EncodeError) -> Self {
crate::error::EncodeError::Serde(val)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/features/serde/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ where
}

fn serialize_seq(mut self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error> {
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 })
}
Expand Down Expand Up @@ -253,7 +253,7 @@ where
}

fn serialize_map(mut self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error> {
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 })
}
Expand Down

0 comments on commit fb27373

Please sign in to comment.