]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #9743 - smoelius:improve-needless-lifetimes, r=Alexendoo
authorbors <bors@rust-lang.org>
Tue, 1 Nov 2022 00:25:30 +0000 (00:25 +0000)
committerbors <bors@rust-lang.org>
Tue, 1 Nov 2022 00:25:30 +0000 (00:25 +0000)
Improve `needless_lifetimes`

This PR makes the following improvements to `needless_lifetimes`.

* It fixes the following false negative, where `foo` is flagged but `bar` is not:
  ```rust
    fn foo<'a>(x: &'a u8, y: &'_ u8) {}

    fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {}
  ```
* It flags more cases, generally. Previously, `needless_borrow` required *all* lifetimes to be used only once. With the changes, individual lifetimes are flagged for being used only once, even if not all lifetimes are.
* Finally, it tries to produce more clear error messages.

changelog: fix `needless_lifetimes` false negative involving functions with multiple unnamed lifetimes
changelog: in `needless_lifetimes`, flag individual lifetimes used only once, rather than require all lifetimes to be used only once
changelog: in `needless_lifetimes`, emit "replace with `'_`" warnings only when applicable, and point to a generic argument

1  2 
clippy_lints/src/dereference.rs

Simple merge