From 8e1ae68569db46251a88997e5e212392d4ad83ea Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 7 Oct 2024 20:54:22 +0200 Subject: [PATCH] Resolve some needless_lifetimes clippy lints warning: the following explicit lifetimes could be elided: 'a --> serde/src/de/mod.rs:489:6 | 489 | impl<'a> Expected for &'a str { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 489 - impl<'a> Expected for &'a str { 489 + impl Expected for &str { | warning: the following explicit lifetimes could be elided: 'a --> serde/src/de/mod.rs:495:6 | 495 | impl<'a> Display for Expected + 'a { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 495 - impl<'a> Display for Expected + 'a { 495 + impl Display for Expected + '_ { | warning: the following explicit lifetimes could be elided: 'a --> serde/src/de/mod.rs:1744:11 | 1744 | impl<'de, 'a, A> SeqAccess<'de> for &'a mut A | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 1744 - impl<'de, 'a, A> SeqAccess<'de> for &'a mut A 1744 + impl<'de, A> SeqAccess<'de> for &mut A | warning: the following explicit lifetimes could be elided: 'a --> serde/src/de/mod.rs:1897:11 | 1897 | impl<'de, 'a, A> MapAccess<'de> for &'a mut A | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 1897 - impl<'de, 'a, A> MapAccess<'de> for &'a mut A 1897 + impl<'de, A> MapAccess<'de> for &mut A | warning: the following explicit lifetimes could be elided: 'a, 'b --> serde/src/ser/fmt.rs:38:6 | 38 | impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> { | ^^ ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 38 - impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> { 38 + impl Serializer for &mut fmt::Formatter<'_> { | warning: the following explicit lifetimes could be elided: 'a --> serde_derive/src/internals/symbol.rs:49:6 | 49 | impl<'a> PartialEq for &'a Ident { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 49 - impl<'a> PartialEq for &'a Ident { 49 + impl PartialEq for &Ident { | warning: the following explicit lifetimes could be elided: 'a --> serde_derive/src/internals/symbol.rs:61:6 | 61 | impl<'a> PartialEq for &'a Path { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 61 - impl<'a> PartialEq for &'a Path { 61 + impl PartialEq for &Path { | --- serde/src/de/mod.rs | 8 ++++---- serde/src/ser/fmt.rs | 2 +- serde_derive/src/internals/symbol.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 21cfd041..b86ebe5e 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -486,13 +486,13 @@ where } } -impl<'a> Expected for &'a str { +impl Expected for &str { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str(self) } } -impl<'a> Display for Expected + 'a { +impl Display for Expected + '_ { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { Expected::fmt(self, formatter) } @@ -1741,7 +1741,7 @@ pub trait SeqAccess<'de> { } } -impl<'de, 'a, A> SeqAccess<'de> for &'a mut A +impl<'de, A> SeqAccess<'de> for &mut A where A: ?Sized + SeqAccess<'de>, { @@ -1894,7 +1894,7 @@ pub trait MapAccess<'de> { } } -impl<'de, 'a, A> MapAccess<'de> for &'a mut A +impl<'de, A> MapAccess<'de> for &mut A where A: ?Sized + MapAccess<'de>, { diff --git a/serde/src/ser/fmt.rs b/serde/src/ser/fmt.rs index 04684ade..4b1549f0 100644 --- a/serde/src/ser/fmt.rs +++ b/serde/src/ser/fmt.rs @@ -35,7 +35,7 @@ macro_rules! fmt_primitives { /// } /// } /// ``` -impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> { +impl<'a> Serializer for &mut fmt::Formatter<'a> { type Ok = (); type Error = fmt::Error; type SerializeSeq = Impossible<(), fmt::Error>; diff --git a/serde_derive/src/internals/symbol.rs b/serde_derive/src/internals/symbol.rs index 572391a8..59ef8de7 100644 --- a/serde_derive/src/internals/symbol.rs +++ b/serde_derive/src/internals/symbol.rs @@ -46,7 +46,7 @@ impl PartialEq for Ident { } } -impl<'a> PartialEq for &'a Ident { +impl PartialEq for &Ident { fn eq(&self, word: &Symbol) -> bool { *self == word.0 } @@ -58,7 +58,7 @@ impl PartialEq for Path { } } -impl<'a> PartialEq for &'a Path { +impl PartialEq for &Path { fn eq(&self, word: &Symbol) -> bool { self.is_ident(word.0) }