Skip to content

Commit

Permalink
chore: fix Clippy warnings on Rust 1.80.1
Browse files Browse the repository at this point in the history
Fix all Clippy warning on the most recent Rust stable release.
  • Loading branch information
vmx committed Aug 12, 2024
1 parent a094e09 commit 0586d72
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::needless_doctest_main)]
#![doc = include_str!("../README.md")]
#![deny(missing_docs)]
#![deny(warnings)]
Expand Down
44 changes: 22 additions & 22 deletions src/serde/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ impl serde::Serializer for Serializer {
}

#[inline]
fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T>(
self,
name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let ipld = value.serialize(self);
if name == CID_SERDE_PRIVATE_IDENTIFIER {
Expand All @@ -226,15 +226,15 @@ impl serde::Serializer for Serializer {
ipld
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let values = BTreeMap::from([(variant.to_owned(), value.serialize(self)?)]);
Ok(Self::Ok::Map(values))
Expand All @@ -246,9 +246,9 @@ impl serde::Serializer for Serializer {
}

#[inline]
fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn serialize_some<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
value.serialize(self)
}
Expand Down Expand Up @@ -341,9 +341,9 @@ impl ser::SerializeSeq for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.vec.push(value.serialize(Serializer)?);
Ok(())
Expand All @@ -358,9 +358,9 @@ impl ser::SerializeTuple for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_element<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_element<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand All @@ -374,9 +374,9 @@ impl ser::SerializeTupleStruct for SerializeVec {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand All @@ -390,9 +390,9 @@ impl ser::SerializeTupleVariant for SerializeTupleVariant {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_field<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.vec.push(value.serialize(Serializer)?);
Ok(())
Expand All @@ -408,9 +408,9 @@ impl ser::SerializeMap for SerializeMap {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<(), Self::Error>
fn serialize_key<T>(&mut self, key: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
match key.serialize(Serializer)? {
Ipld::String(string_key) => {
Expand All @@ -421,9 +421,9 @@ impl ser::SerializeMap for SerializeMap {
}
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<(), Self::Error>
fn serialize_value<T>(&mut self, value: &T) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
let key = self.next_key.take();
// Panic because this indicates a bug in the program rather than an
Expand All @@ -442,13 +442,13 @@ impl ser::SerializeStruct for SerializeMap {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
serde::ser::SerializeMap::serialize_key(self, key)?;
serde::ser::SerializeMap::serialize_value(self, value)
Expand All @@ -463,13 +463,13 @@ impl ser::SerializeStructVariant for SerializeStructVariant {
type Ok = Ipld;
type Error = SerdeError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: ser::Serialize,
T: ser::Serialize + ?Sized,
{
self.map
.insert(key.to_string(), value.serialize(Serializer)?);
Expand Down

0 comments on commit 0586d72

Please sign in to comment.