Repository: jonasbb/serde_with
Pull request #789 (2024-10-05 19:06:56)

Fix clippy::needless_lifetimes


Patch:
diff --git a/serde_with/src/base64.rs b/serde_with/src/base64.rs
index cedc4f2..cbae899 100644
--- a/serde_with/src/base64.rs
+++ b/serde_with/src/base64.rs
@@ -122,7 +122,7 @@ where
     {
         struct Helper<T, ALPHABET>(PhantomData<(T, ALPHABET)>);
 
-        impl<'de, T, ALPHABET> Visitor<'de> for Helper<T, ALPHABET>
+        impl<T, ALPHABET> Visitor<'_> for Helper<T, ALPHABET>
         where
             T: TryFrom<Vec<u8>>,
             ALPHABET: Alphabet,
diff --git a/serde_with/src/chrono_0_4.rs b/serde_with/src/chrono_0_4.rs
index 250f029..66fee5b 100644
--- a/serde_with/src/chrono_0_4.rs
+++ b/serde_with/src/chrono_0_4.rs
@@ -64,7 +64,7 @@ pub mod datetime_utc_ts_seconds_from_any {
         D: Deserializer<'de>,
     {
         struct Helper;
-        impl<'de> Visitor<'de> for Helper {
+        impl Visitor<'_> for Helper {
             type Value = DateTime<Utc>;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/serde_with/src/content/de.rs b/serde_with/src/content/de.rs
index e6bbf51..a81a9e2 100644
--- a/serde_with/src/content/de.rs
+++ b/serde_with/src/content/de.rs
@@ -57,7 +57,7 @@ pub(crate) enum Content<'de> {
     Map(Vec<(Content<'de>, Content<'de>)>),
 }
 
-impl<'de> Content<'de> {
+impl Content<'_> {
     #[cold]
     fn unexpected(&self) -> Unexpected<'_> {
         match *self {
@@ -1123,7 +1123,7 @@ pub struct ContentRefDeserializer<'a, 'de, E> {
     err: PhantomData<E>,
 }
 
-impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E>
+impl<'de, E> ContentRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1214,7 +1214,7 @@ where
 
 /// Used when deserializing an untagged enum because the content may need
 /// to be used more than once.
-impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
+impl<'de, E> Deserializer<'de> for ContentRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1631,7 +1631,7 @@ where
     err: PhantomData<E>,
 }
 
-impl<'de, 'a, E> VariantAccess<'de> for VariantRefDeserializer<'a, 'de, E>
+impl<'de, E> VariantAccess<'de> for VariantRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1726,7 +1726,7 @@ where
     }
 }
 
-impl<'de, 'a, E> Deserializer<'de> for SeqRefDeserializer<'a, 'de, E>
+impl<'de, E> Deserializer<'de> for SeqRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1763,7 +1763,7 @@ where
     }
 }
 
-impl<'de, 'a, E> SeqAccess<'de> for SeqRefDeserializer<'a, 'de, E>
+impl<'de, E> SeqAccess<'de> for SeqRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1810,7 +1810,7 @@ where
     }
 }
 
-impl<'de, 'a, E> MapAccess<'de> for MapRefDeserializer<'a, 'de, E>
+impl<'de, E> MapAccess<'de> for MapRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1847,7 +1847,7 @@ where
     }
 }
 
-impl<'de, 'a, E> Deserializer<'de> for MapRefDeserializer<'a, 'de, E>
+impl<'de, E> Deserializer<'de> for MapRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
@@ -1884,7 +1884,7 @@ where
     }
 }
 
-impl<'de, 'a, E> IntoDeserializer<'de, E> for ContentRefDeserializer<'a, 'de, E>
+impl<'de, E> IntoDeserializer<'de, E> for ContentRefDeserializer<'_, 'de, E>
 where
     E: DeError,
 {
diff --git a/serde_with/src/de/impls.rs b/serde_with/src/de/impls.rs
index de00509..2547420 100644
--- a/serde_with/src/de/impls.rs
+++ b/serde_with/src/de/impls.rs
@@ -868,7 +868,7 @@ where
         D: Deserializer<'de>,
     {
         struct Helper<S>(PhantomData<S>);
-        impl<'de, S> Visitor<'de> for Helper<S>
+        impl<S> Visitor<'_> for Helper<S>
         where
             S: FromStr,
             <S as FromStr>::Err: Display,
@@ -918,7 +918,7 @@ where
         D: Deserializer<'de>,
     {
         struct OptionStringEmptyNone<S>(PhantomData<S>);
-        impl<'de, S> Visitor<'de> for OptionStringEmptyNone<S>
+        impl<S> Visitor<'_> for OptionStringEmptyNone<S>
         where
             S: FromStr,
             S::Err: Display,
@@ -1036,7 +1036,7 @@ where
     {
         struct Helper<SEPARATOR, I, T>(PhantomData<(SEPARATOR, I, T)>);
 
-        impl<'de, SEPARATOR, I, T> Visitor<'de> for Helper<SEPARATOR, I, T>
+        impl<SEPARATOR, I, T> Visitor<'_> for Helper<SEPARATOR, I, T>
         where
             SEPARATOR: Separator,
             I: FromIterator<T>,
@@ -1811,7 +1811,7 @@ impl<'de> DeserializeAs<'de, bool> for BoolFromInt<Strict> {
         D: Deserializer<'de>,
     {
         struct U8Visitor;
-        impl<'de> Visitor<'de> for U8Visitor {
+        impl Visitor<'_> for U8Visitor {
             type Value = bool;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -1910,7 +1910,7 @@ impl<'de> DeserializeAs<'de, bool> for BoolFromInt<Flexible> {
         D: Deserializer<'de>,
     {
         struct U8Visitor;
-        impl<'de> Visitor<'de> for U8Visitor {
+        impl Visitor<'_> for U8Visitor {
             type Value = bool;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/serde_with/src/enum_map.rs b/serde_with/src/enum_map.rs
index 04b9871..6929964 100644
--- a/serde_with/src/enum_map.rs
+++ b/serde_with/src/enum_map.rs
@@ -649,7 +649,7 @@ struct SerializeVariant<'a, M> {
     content: Content,
 }
 
-impl<'a, M> SerializeStructVariant for SerializeVariant<'a, M>
+impl<M> SerializeStructVariant for SerializeVariant<'_, M>
 where
     M: SerializeMap,
 {
@@ -674,7 +674,7 @@ where
     }
 }
 
-impl<'a, M> SerializeTupleVariant for SerializeVariant<'a, M>
+impl<M> SerializeTupleVariant for SerializeVariant<'_, M>
 where
     M: SerializeMap,
 {
diff --git a/serde_with/src/json.rs b/serde_with/src/json.rs
index 5a192e1..091f712 100644
--- a/serde_with/src/json.rs
+++ b/serde_with/src/json.rs
@@ -96,7 +96,7 @@ where
     {
         struct Helper<S, SAs>(PhantomData<(S, SAs)>);
 
-        impl<'de, S, SAs> Visitor<'de> for Helper<S, SAs>
+        impl<S, SAs> Visitor<'_> for Helper<S, SAs>
         where
             SAs: for<'a> DeserializeAs<'a, S>,
         {
diff --git a/serde_with/src/key_value_map.rs b/serde_with/src/key_value_map.rs
index 3a16735..420ce12 100644
--- a/serde_with/src/key_value_map.rs
+++ b/serde_with/src/key_value_map.rs
@@ -671,7 +671,7 @@ struct KeyValueSeqSerializer<'a, M> {
     key: Option<SerContent>,
 }
 
-impl<'a, M> SerializeSeq for KeyValueSeqSerializer<'a, M>
+impl<M> SerializeSeq for KeyValueSeqSerializer<'_, M>
 where
     M: SerializeMap,
 {
@@ -712,7 +712,7 @@ struct KeyValueTupleSerializer<'a, M> {
     key: Option<SerContent>,
 }
 
-impl<'a, M> SerializeTuple for KeyValueTupleSerializer<'a, M>
+impl<M> SerializeTuple for KeyValueTupleSerializer<'_, M>
 where
     M: SerializeMap,
 {
@@ -754,7 +754,7 @@ struct KeyValueTupleStructSerializer<'a, M> {
     key: Option<SerContent>,
 }
 
-impl<'a, M> SerializeTupleStruct for KeyValueTupleStructSerializer<'a, M>
+impl<M> SerializeTupleStruct for KeyValueTupleStructSerializer<'_, M>
 where
     M: SerializeMap,
 {
@@ -796,7 +796,7 @@ struct KeyValueMapSerializer<'a, M> {
     tmp: Option<SerContent>,
 }
 
-impl<'a, M> SerializeMap for KeyValueMapSerializer<'a, M>
+impl<M> SerializeMap for KeyValueMapSerializer<'_, M>
 where
     M: SerializeMap,
 {
@@ -857,7 +857,7 @@ struct KeyValueStructSerializer<'a, M> {
     key: Option<SerContent>,
 }
 
-impl<'a, M> SerializeStruct for KeyValueStructSerializer<'a, M>
+impl<M> SerializeStruct for KeyValueStructSerializer<'_, M>
 where
     M: SerializeMap,
 {
diff --git a/serde_with/src/ser/mod.rs b/serde_with/src/ser/mod.rs
index 42895b8..db1d3d4 100644
--- a/serde_with/src/ser/mod.rs
+++ b/serde_with/src/ser/mod.rs
@@ -133,7 +133,7 @@ where
     }
 }
 
-impl<'a, T, U> Serialize for SerializeAsWrap<'a, T, U>
+impl<T, U> Serialize for SerializeAsWrap<'_, T, U>
 where
     T: ?Sized,
     U: ?Sized,
diff --git a/serde_with/src/time_0_3.rs b/serde_with/src/time_0_3.rs
index acc3895..6574f46 100644
--- a/serde_with/src/time_0_3.rs
+++ b/serde_with/src/time_0_3.rs
@@ -539,7 +539,7 @@ impl<'de> DeserializeAs<'de, OffsetDateTime> for Rfc2822 {
         D: Deserializer<'de>,
     {
         struct Helper;
-        impl<'de> Visitor<'de> for Helper {
+        impl Visitor<'_> for Helper {
             type Value = OffsetDateTime;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -575,7 +575,7 @@ impl<'de> DeserializeAs<'de, OffsetDateTime> for Rfc3339 {
         D: Deserializer<'de>,
     {
         struct Helper;
-        impl<'de> Visitor<'de> for Helper {
+        impl Visitor<'_> for Helper {
             type Value = OffsetDateTime;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -611,7 +611,7 @@ impl<'de, const CONFIG: EncodedConfig> DeserializeAs<'de, OffsetDateTime> for Is
         D: Deserializer<'de>,
     {
         struct Helper<const CONFIG: EncodedConfig>;
-        impl<'de, const CONFIG: EncodedConfig> Visitor<'de> for Helper<CONFIG> {
+        impl<const CONFIG: EncodedConfig> Visitor<'_> for Helper<CONFIG> {
             type Value = OffsetDateTime;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/serde_with/src/utils/duration.rs b/serde_with/src/utils/duration.rs
index 2e6aecb..27332bb 100644
--- a/serde_with/src/utils/duration.rs
+++ b/serde_with/src/utils/duration.rs
@@ -296,7 +296,7 @@ duration_impls!(
 );
 
 struct DurationVisitorFlexible;
-impl<'de> Visitor<'de> for DurationVisitorFlexible {
+impl Visitor<'_> for DurationVisitorFlexible {
     type Value = DurationSigned;
 
     fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -386,7 +386,7 @@ impl<'de> DeserializeAs<'de, DurationSigned> for DurationSeconds<String, Strict>
     {
         struct DurationDeserializationVisitor;
 
-        impl<'de> Visitor<'de> for DurationDeserializationVisitor {
+        impl Visitor<'_> for DurationDeserializationVisitor {
             type Value = DurationSigned;
 
             fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/serde_with/src/with_prefix.rs b/serde_with/src/with_prefix.rs
index f5a5d41..db18ca0 100644
--- a/serde_with/src/with_prefix.rs
+++ b/serde_with/src/with_prefix.rs
@@ -140,7 +140,7 @@ pub struct WithPrefix<'a, T> {
     pub prefix: &'a str,
 }
 
-impl<'a, T> Serialize for WithPrefix<'a, T>
+impl<T> Serialize for WithPrefix<'_, T>
 where
     T: Serialize,
 {
@@ -333,7 +333,7 @@ where
     }
 }
 
-impl<'a, S> SerializeMap for WithPrefix<'a, S>
+impl<S> SerializeMap for WithPrefix<'_, S>
 where
     S: SerializeMap,
 {
@@ -376,7 +376,7 @@ where
     }
 }
 
-impl<'a, S> SerializeStruct for WithPrefix<'a, S>
+impl<S> SerializeStruct for WithPrefix<'_, S>
 where
     S: SerializeMap,
 {
@@ -398,7 +398,7 @@ where
     }
 }
 
-impl<'de, 'a, T> DeserializeSeed<'de> for WithPrefix<'a, T>
+impl<'de, T> DeserializeSeed<'de> for WithPrefix<'_, T>
 where
     T: DeserializeSeed<'de>,
 {
@@ -415,7 +415,7 @@ where
     }
 }
 
-impl<'de, 'a, D> Deserializer<'de> for WithPrefix<'a, D>
+impl<'de, D> Deserializer<'de> for WithPrefix<'_, D>
 where
     D: Deserializer<'de>,
 {
@@ -459,7 +459,7 @@ where
     }
 }
 
-impl<'de, 'a, V> Visitor<'de> for WithPrefix<'a, V>
+impl<'de, V> Visitor<'de> for WithPrefix<'_, V>
 where
     V: Visitor<'de>,
 {
@@ -480,7 +480,7 @@ where
     }
 }
 
-impl<'de, 'a, A> MapAccess<'de> for WithPrefix<'a, A>
+impl<'de, A> MapAccess<'de> for WithPrefix<'_, A>
 where
     A: MapAccess<'de>,
 {
@@ -515,7 +515,7 @@ pub struct WithPrefixOption<'a, T> {
     prefix: &'a str,
 }
 
-impl<'de, 'a, V> Visitor<'de> for WithPrefixOption<'a, V>
+impl<'de, V> Visitor<'de> for WithPrefixOption<'_, V>
 where
     V: Visitor<'de>,
 {
@@ -550,7 +550,7 @@ where
     }
 }
 
-impl<'de, 'a, A> Deserializer<'de> for WithPrefixOption<'a, A>
+impl<'de, A> Deserializer<'de> for WithPrefixOption<'_, A>
 where
     A: MapAccess<'de>,
 {
@@ -570,7 +570,7 @@ where
     }
 }
 
-impl<'de, 'a, A> MapAccess<'de> for WithPrefixOption<'a, A>
+impl<'de, A> MapAccess<'de> for WithPrefixOption<'_, A>
 where
     A: MapAccess<'de>,
 {
diff --git a/serde_with_macros/src/utils.rs b/serde_with_macros/src/utils.rs
index 4bc08cb..e0d364c 100644
--- a/serde_with_macros/src/utils.rs
+++ b/serde_with_macros/src/utils.rs
@@ -66,7 +66,7 @@ pub(crate) fn split_with_de_lifetime(
 
 pub(crate) struct DeImplGenerics<'a>(&'a Generics);
 
-impl<'a> ToTokens for DeImplGenerics<'a> {
+impl ToTokens for DeImplGenerics<'_> {
     fn to_tokens(&self, tokens: &mut TokenStream2) {
         let mut generics = self.0.clone();
         generics.params = Some(parse_quote!('de))


Test patch:
diff --git a/serde_with/tests/serde_as/map_tuple_list.rs b/serde_with/tests/serde_as/map_tuple_list.rs
index 90cbfbb..39ab3d7 100644
--- a/serde_with/tests/serde_as/map_tuple_list.rs
+++ b/serde_with/tests/serde_as/map_tuple_list.rs
@@ -391,7 +391,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
 
     struct TestSerializer;
 
-    impl<'a> Serializer for &'a mut TestSerializer {
+    impl Serializer for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
         type SerializeSeq = Self;
@@ -559,7 +559,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeMap for &'a mut TestSerializer {
+    impl SerializeMap for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -582,7 +582,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeSeq for &'a mut TestSerializer {
+    impl SerializeSeq for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -598,7 +598,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeStruct for &'a mut TestSerializer {
+    impl SerializeStruct for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -614,7 +614,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeStructVariant for &'a mut TestSerializer {
+    impl SerializeStructVariant for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -630,7 +630,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeTuple for &'a mut TestSerializer {
+    impl SerializeTuple for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -646,7 +646,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeTupleStruct for &'a mut TestSerializer {
+    impl SerializeTupleStruct for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;
 
@@ -662,7 +662,7 @@ fn test_map_as_tuple_list_works_with_serializer_that_needs_length_to_serialize_s
         }
     }
 
-    impl<'a> SerializeTupleVariant for &'a mut TestSerializer {
+    impl SerializeTupleVariant for &mut TestSerializer {
         type Ok = ();
         type Error = TestError;