Skip to content

Commit

Permalink
Resolve some needless_lifetimes clippy lints
Browse files Browse the repository at this point in the history
    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<T> 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<T> 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<T> 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<T> 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<T> 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 {
       |
  • Loading branch information
dtolnay committed Oct 7, 2024
1 parent 53df889 commit 9f4279f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ impl<T: ?Sized> DerefMut for NoDrop<T> {
pub(crate) trait TrivialDrop {}

impl<T> TrivialDrop for iter::Empty<T> {}
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<T> TrivialDrop for slice::Iter<'_, T> {}
impl<T> TrivialDrop for slice::IterMut<'_, T> {}
impl<T> TrivialDrop for option::IntoIter<&T> {}
impl<T> TrivialDrop for option::IntoIter<&mut T> {}

#[test]
fn test_needs_drop() {
Expand Down
2 changes: 1 addition & 1 deletion tests/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Debug for Lite<TokenStream> {
}
}

impl<'a, T> Debug for Lite<&'a T>
impl<T> Debug for Lite<&T>
where
Lite<T>: Debug,
{
Expand Down
2 changes: 1 addition & 1 deletion tests/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub trait TryIntoTokens {
fn try_into_tokens(self) -> Result<proc_macro2::TokenStream>;
}

impl<'a> TryIntoTokens for &'a str {
impl TryIntoTokens for &str {
fn try_into_tokens(self) -> Result<proc_macro2::TokenStream> {
let tokens = proc_macro2::TokenStream::from_str(self)?;
Ok(tokens)
Expand Down

0 comments on commit 9f4279f

Please sign in to comment.