From 9f4279fa80bfbf4169037b06d387a824729f578d Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 7 Oct 2024 21:25:19 +0200 Subject: [PATCH] Resolve some needless_lifetimes clippy lints warning: the following explicit lifetimes could be elided: 'a --> src/drops.rs:35:6 | 35 | impl<'a, T> TrivialDrop for slice::Iter<'a, T> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 35 - impl<'a, T> TrivialDrop for slice::Iter<'a, T> {} 35 + impl TrivialDrop for slice::Iter<'_, T> {} | warning: the following explicit lifetimes could be elided: 'a --> src/drops.rs:36:6 | 36 | impl<'a, T> TrivialDrop for slice::IterMut<'a, T> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 36 - impl<'a, T> TrivialDrop for slice::IterMut<'a, T> {} 36 + impl TrivialDrop for slice::IterMut<'_, T> {} | warning: the following explicit lifetimes could be elided: 'a --> src/drops.rs:37:6 | 37 | impl<'a, T> TrivialDrop for option::IntoIter<&'a T> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 37 - impl<'a, T> TrivialDrop for option::IntoIter<&'a T> {} 37 + impl TrivialDrop for option::IntoIter<&T> {} | warning: the following explicit lifetimes could be elided: 'a --> src/drops.rs:38:6 | 38 | impl<'a, T> TrivialDrop for option::IntoIter<&'a mut T> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 38 - impl<'a, T> TrivialDrop for option::IntoIter<&'a mut T> {} 38 + impl TrivialDrop for option::IntoIter<&mut T> {} | warning: the following explicit lifetimes could be elided: 'a --> tests/debug/mod.rs:85:6 | 85 | impl<'a, T> Debug for Lite<&'a T> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `-W clippy::needless-lifetimes` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::needless_lifetimes)]` help: elide the lifetimes | 85 - impl<'a, T> Debug for Lite<&'a T> 85 + impl Debug for Lite<&T> | warning: the following explicit lifetimes could be elided: 'a --> tests/macros/mod.rs:82:6 | 82 | impl<'a> TryIntoTokens for &'a str { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 82 - impl<'a> TryIntoTokens for &'a str { 82 + impl TryIntoTokens for &str { | --- src/drops.rs | 8 ++++---- tests/debug/mod.rs | 2 +- tests/macros/mod.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/drops.rs b/src/drops.rs index 89b42d82ef..c54308f02c 100644 --- a/src/drops.rs +++ b/src/drops.rs @@ -32,10 +32,10 @@ impl DerefMut for NoDrop { pub(crate) trait TrivialDrop {} impl TrivialDrop for iter::Empty {} -impl<'a, T> TrivialDrop for slice::Iter<'a, T> {} -impl<'a, T> TrivialDrop for slice::IterMut<'a, T> {} -impl<'a, T> TrivialDrop for option::IntoIter<&'a T> {} -impl<'a, T> TrivialDrop for option::IntoIter<&'a mut T> {} +impl TrivialDrop for slice::Iter<'_, T> {} +impl TrivialDrop for slice::IterMut<'_, T> {} +impl TrivialDrop for option::IntoIter<&T> {} +impl TrivialDrop for option::IntoIter<&mut T> {} #[test] fn test_needs_drop() { diff --git a/tests/debug/mod.rs b/tests/debug/mod.rs index c9925a6d5c..7ab2b795d5 100644 --- a/tests/debug/mod.rs +++ b/tests/debug/mod.rs @@ -82,7 +82,7 @@ impl Debug for Lite { } } -impl<'a, T> Debug for Lite<&'a T> +impl Debug for Lite<&T> where Lite: Debug, { diff --git a/tests/macros/mod.rs b/tests/macros/mod.rs index 1c1bacf459..024075c046 100644 --- a/tests/macros/mod.rs +++ b/tests/macros/mod.rs @@ -79,7 +79,7 @@ pub trait TryIntoTokens { fn try_into_tokens(self) -> Result; } -impl<'a> TryIntoTokens for &'a str { +impl TryIntoTokens for &str { fn try_into_tokens(self) -> Result { let tokens = proc_macro2::TokenStream::from_str(self)?; Ok(tokens)