9

Improve `needless_lifetimes` by smoelius · Pull Request #9743 · rust-lang/rust-c...

 1 year ago
source link: https://github.com/rust-lang/rust-clippy/pull/9743
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Contributor

@smoelius smoelius commented Oct 28, 2022

edited

This PR makes the following improvements to needless_lifetimes.

  • It fixes the following false negative, where foo is flagged but bar is not:
      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

All reactions

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK