From 300e7e577d62b012d882f935c2a9439ca1f726d1 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Tue, 9 Jan 2024 16:29:11 +0100 Subject: [PATCH] Fix CI (#196) * chore: fix Clippy warnings * test: don't match on specific panic Recent Rust versions (>=1.73.0) changed the wording when using `assert_eq!()`. This made a test fail, as it was targeted at a specific message. As this message could change any time (as it's not under our control), just remove that exact matching, and just match on any panic. Closes #195. --- core/src/codec.rs | 9 ++++++--- core/tests/serde_deserialize.rs | 2 +- dag-cbor/tests/serde_interop.rs | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/codec.rs b/core/src/codec.rs index 89f02db0..15b3c8a4 100644 --- a/core/src/codec.rs +++ b/core/src/codec.rs @@ -1,6 +1,6 @@ //! `Ipld` codecs. -use alloc::{format, string::String, vec::Vec}; -use core::convert::TryFrom; +use alloc::{string::String, vec::Vec}; +use core::{convert::TryFrom, fmt::Write as _}; use crate::cid::Cid; use crate::error::{Result, UnsupportedCodec}; @@ -85,7 +85,10 @@ where Ipld: Decode + Encode, { fn hex(bytes: &[u8]) -> String { - bytes.iter().map(|byte| format!("{:02x}", byte)).collect() + bytes.iter().fold(String::new(), |mut output, byte| { + let _ = write!(output, "{byte:02x}"); + output + }) } let mut bytes = Vec::new(); data.encode(c, &mut bytes).unwrap(); diff --git a/core/tests/serde_deserialize.rs b/core/tests/serde_deserialize.rs index 3e67ce2d..205ca60d 100644 --- a/core/tests/serde_deserialize.rs +++ b/core/tests/serde_deserialize.rs @@ -143,7 +143,7 @@ fn ipld_deserialize_link() { } #[test] -#[should_panic(expected = "assertion failed")] +#[should_panic] fn ipld_deserialize_link_not_as_bytes() { let cid = Cid::try_from("bafkreie74tgmnxqwojhtumgh5dzfj46gi4mynlfr7dmm7duwzyvnpw7h7m").unwrap(); let ipld = Ipld::Link(cid); diff --git a/dag-cbor/tests/serde_interop.rs b/dag-cbor/tests/serde_interop.rs index 40adaf52..5821f07a 100644 --- a/dag-cbor/tests/serde_interop.rs +++ b/dag-cbor/tests/serde_interop.rs @@ -41,8 +41,7 @@ impl Arbitrary for ValueArb { .into_iter() .map(|x| { let slf = Self(x); - let shrunk = slf.shrink().map(|x| x.0).collect::>(); - shrunk + slf.shrink().map(|x| x.0).collect::>() }) .map(Value::Array) .map(Self),