Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve needless_lifetimes #9743

Merged
merged 4 commits into from
Nov 1, 2022

Conversation

smoelius
Copy link
Contributor

@smoelius smoelius commented Oct 28, 2022

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

@rust-highfive
Copy link

r? @Alexendoo

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 28, 2022
Copy link
Member

@Alexendoo Alexendoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Just a few small things/questions

Catching those <'a, 'tcx> ones is great

tests/ui/needless_lifetimes.rs Outdated Show resolved Hide resolved
clippy_lints/src/lifetimes.rs Outdated Show resolved Hide resolved
clippy_lints/src/lifetimes.rs Outdated Show resolved Hide resolved
clippy_lints/src/lifetimes.rs Outdated Show resolved Hide resolved
@xFrednet
Copy link
Member

Hey, could you maybe expand the changelog entry a bit? It fine if it spans over multiple lines for complex changes. You're welcome to reach out if you want some assistance :)

@smoelius
Copy link
Contributor Author

@xFrednet

You're welcome to reach out if you want some assistance :)

To be completely honest, I have never completely understood what should go in those entries.

  • Re level of detail, could you maybe point me to a particularly good example?
  • I presume those entries drive the creation of Clippy's actual CHANGELOG.md, but there doesn't appear to be a 1-1 correspondence. Could you maybe share some details of how the one feeds into the other?
  • Finally, can multiple line entries literally contain newlines? Is there a desired prefix/format for the additional lines?

@xFrednet
Copy link
Member

In Clippy, we create the changelog based on these comments. Every release, someone gets all commits from bors with a changelog: XYZ entry and combines them into the changelog. This is a manual process. I usually try to align the general format of these entries. For instance, new lints are just listed with their names, while moves are often written as * Moved [`XYZ`] to `Duck` (now allow-by-default). So, there is no 1-1 correspondence due to this process.

Re level of detail, could you maybe point me to a particularly good example?

Sadly, I have no direct example, the entries of the changelog are a good level. Interested users open the PR if they really want additional information. The rule of thumb is basically what do you believe is important for an outsider perspective. Often, PRs are only related to a single property of the lint, and then it's good to list that one. Otherwise, it's better to include too much detail than too little. I sometimes look at the changelog and then adapt an existing entry to my change.

Finally, can multiple line entries literally contain newlines? Is there a desired prefix/format for the additional lines?

There is no fixed format, also because it would be more work to enforce than actually beneficial. The main point is, that the writer should clearly see that the lines belong together. I've seen and liked this:

changelog: Something 1
changelog: Something 2
changelog: Something 3

We could be a bit clearer on the creation of the changelog. I hope this answers your questions, reach out if I missed a point, or you would like more context :)

@smoelius
Copy link
Contributor Author

@xFrednet Please tell me if what I have now suffices.

@xFrednet
Copy link
Member

I'm unsure which false negative you mean with the first entry:

changelog: fix needless_borrow false negative

The others are excellent, thank you very much for the update.

@Alexendoo
Copy link
Member

Here's some added cases it lints to skim through, looks good to me

warning: the following explicit lifetimes could be elided: 'a
   --> clap-3.2.16/src/parser/arg_matcher.rs:139:5
    |
139 |     pub(crate) fn check_explicit<'a>(&self, arg: &Id, predicate: ArgPredicate<'a>) -> bool {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-3.2.16/src/parser/arg_matcher.rs:139:79
    |
139 |     pub(crate) fn check_explicit<'a>(&self, arg: &Id, predicate: ArgPredicate<'a>) -> bool {
    |                                                                               ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'k
   --> hyper-0.10.16/src/server/mod.rs:410:5
    |
410 |     fn handle<'a, 'k>(&'a self, Request<'a, 'k>, Response<'a, Fresh>);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> hyper-0.10.16/src/server/mod.rs:410:45
    |
410 |     fn handle<'a, 'k>(&'a self, Request<'a, 'k>, Response<'a, Fresh>);
    |                                             ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'b
   --> httparse-1.3.4/src/lib.rs:575:1
    |
575 | / fn parse_headers_iter<'a, 'b>(headers: &mut &mut [Header<'a>], bytes: &'b mut Bytes<'a>)
576 | |     -> Result<usize> {
    | |____________________^
    |
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'b
   --> textwrap-0.15.0/src/wrap_algorithms.rs:315:1
    |
315 | / pub fn wrap_first_fit<'a, 'b, T: Fragment>(
316 | |     fragments: &'a [T],
317 | |     line_widths: &'b [f64],
318 | | ) -> Vec<&'a [T]> {
    | |_________________^
    |
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.147/src/ser.rs:953:1
    |
953 | / fn serialize_struct_variant_with_flatten<'a>(
954 | |     context: StructVariant<'a>,
955 | |     params: &Parameters,
956 | |     fields: &[Field],
957 | |     name: &str,
958 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.147/src/ser.rs:954:28
    |
954 |     context: StructVariant<'a>,
    |                            ^^

warning: the following explicit lifetimes could be elided: 'a
   --> idna-0.2.2/src/uts46.rs:454:5
    |
454 |     pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'c
  --> toml_edit-0.14.4/src/inline_table.rs:57:5
   |
57 | /     pub(crate) fn append_values<'s, 'c>(
58 | |         &'s self,
59 | |         parent: &[&'s Key],
60 | |         values: &'c mut Vec<(Vec<&'s Key>, &'s Value)>,
61 | |     ) {
   | |______^
   |
   = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.110/src/ser.rs:949:1
    |
949 | / fn serialize_struct_variant_with_flatten<'a>(
950 | |     context: StructVariant<'a>,
951 | |     params: &Parameters,
952 | |     fields: &[Field],
953 | |     name: &str,
954 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.110/src/ser.rs:950:28
    |
950 |     context: StructVariant<'a>,
    |                            ^^

warning: the following explicit lifetimes could be elided: 'a
   --> idna-0.2.3/src/uts46.rs:453:5
    |
453 |     pub fn to_ascii<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'c
  --> toml_edit-0.14.4/src/table.rs:72:5
   |
72 | /     fn append_values<'s, 'c>(
73 | |         &'s self,
74 | |         parent: &[&'s Key],
75 | |         values: &'c mut Vec<(Vec<&'s Key>, &'s Value)>,
76 | |     ) {
   | |______^

warning: the following explicit lifetimes could be elided: 'k
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/cargo_add/dependency.rs:480:5
    |
480 | /     pub fn update_toml<'k>(
481 | |         &self,
482 | |         crate_root: &Path,
483 | |         key: &mut KeyMut<'k>,
484 | |         item: &mut toml_edit::Item,
485 | |     ) {
    | |______^
    |
help: replace with `'_` in generic arguments such as here
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/cargo_add/dependency.rs:483:26
    |
483 |         key: &mut KeyMut<'k>,
    |                          ^^

warning: the following explicit lifetimes could be elided: 'a
   --> idna-0.2.2/src/uts46.rs:495:5
    |
495 |     pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: the following explicit lifetimes could be elided: 'b, 'c
   --> clap-2.33.1/src/app/help.rs:296:5
    |
296 |     fn long<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/help.rs:296:53
    |
296 |     fn long<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |                                                     ^^

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.110/src/ser.rs:865:1
    |
865 | / fn serialize_struct_variant<'a>(
866 | |     context: StructVariant<'a>,
867 | |     params: &Parameters,
868 | |     fields: &[Field],
869 | |     name: &str,
870 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.110/src/ser.rs:866:28
    |
866 |     context: StructVariant<'a>,
    |                            ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.123/src/ser.rs:869:1
    |
869 | / fn serialize_struct_variant<'a>(
870 | |     context: StructVariant<'a>,
871 | |     params: &Parameters,
872 | |     fields: &[Field],
873 | |     name: &str,
874 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.123/src/ser.rs:870:28
    |
870 |     context: StructVariant<'a>,
    |                            ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.147/src/ser.rs:869:1
    |
869 | / fn serialize_struct_variant<'a>(
870 | |     context: StructVariant<'a>,
871 | |     params: &Parameters,
872 | |     fields: &[Field],
873 | |     name: &str,
874 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.147/src/ser.rs:870:28
    |
870 |     context: StructVariant<'a>,
    |                            ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> chrono-0.4.19/src/format/mod.rs:404:1
    |
404 | / fn format_inner<'a>(
405 | |     result: &mut String,
406 | |     date: Option<&NaiveDate>,
407 | |     time: Option<&NaiveTime>,
...   |
410 | |     _locale: Option<Locale>,
411 | | ) -> fmt::Result {
    | |________________^
    |
help: replace with `'_` in generic arguments such as here
   --> chrono-0.4.19/src/format/mod.rs:409:17
    |
409 |     item: &Item<'a>,
    |                 ^^

warning: the following explicit lifetimes could be elided: 'a
  --> grep-printer-0.1.5/src/util.rs:53:5
   |
53 | /     pub fn replace_all<'a>(
54 | |         &'a mut self,
55 | |         matcher: &M,
56 | |         subject: &[u8],
57 | |         replacement: &[u8],
58 | |     ) -> io::Result<()> {
   | |_______________________^

warning: the following explicit lifetimes could be elided: 's
   --> grep-printer-0.1.5/src/summary.rs:369:5
    |
369 | /     pub fn sink<'s, M: Matcher>(
370 | |         &'s mut self,
371 | |         matcher: M,
372 | |     ) -> SummarySink<'static, 's, M, W> {
    | |_______________________________________^
    |
help: replace with `'_` in generic arguments such as here
   --> grep-printer-0.1.5/src/summary.rs:372:31
    |
372 |     ) -> SummarySink<'static, 's, M, W> {
    |                               ^^

warning: the following explicit lifetimes could be elided: 'a, 'b
  --> clap-2.33.1/src/completions/powershell.rs:74:1
   |
74 | / fn generate_inner<'a, 'b, 'p>(
75 | |     p: &'p Parser<'a, 'b>,
76 | |     previous_command_name: &str,
77 | |     names: &mut Vec<&'p str>,
78 | | ) -> String {
   | |___________^
   |
help: replace with `'_` in generic arguments such as here
  --> clap-2.33.1/src/completions/powershell.rs:75:19
   |
75 |     p: &'p Parser<'a, 'b>,
   |                   ^^

warning: the following explicit lifetimes could be elided: 'a
   --> idna-0.2.3/src/uts46.rs:494:5
    |
494 |     pub fn to_unicode<'a>(&'a mut self, domain: &str, out: &mut String) -> Result<(), Errors> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.143/src/ser.rs:953:1
    |
953 | / fn serialize_struct_variant_with_flatten<'a>(
954 | |     context: StructVariant<'a>,
955 | |     params: &Parameters,
956 | |     fields: &[Field],
957 | |     name: &str,
958 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.143/src/ser.rs:954:28
    |
954 |     context: StructVariant<'a>,
    |                            ^^

warning: the following explicit lifetimes could be elided: 'a
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/tree/mod.rs:273:1
    |
273 | / fn print_node<'a>(
274 | |     config: &Config,
275 | |     graph: &'a Graph<'_>,
276 | |     node_index: usize,
...   |
286 | |     print_stack: &mut Vec<usize>,
287 | | ) {
    | |__^

warning: the following explicit lifetimes could be elided: 'b
   --> clap-2.33.1/src/app/usage.rs:322:1
    |
322 | / pub fn get_required_usage_from<'a, 'b>(
323 | |     p: &Parser<'a, 'b>,
324 | |     reqs: &[&'a str],
325 | |     matcher: Option<&ArgMatcher<'a>>,
326 | |     extra: Option<&str>,
327 | |     incl_last: bool,
328 | | ) -> VecDeque<String> {
    | |_____________________^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/usage.rs:323:20
    |
323 |     p: &Parser<'a, 'b>,
    |                    ^^

warning: the following explicit lifetimes could be elided: 'k
  --> toml_edit-0.14.4/src/parser/table.rs:88:5
   |
88 | /     pub(crate) fn descend_path<'t, 'k>(
89 | |         mut table: &'t mut Table,
90 | |         path: &'k [Key],
91 | |         dotted: bool,
92 | |     ) -> Result<&'t mut Table, CustomError> {
   | |___________________________________________^

warning: the following explicit lifetimes could be elided: 'b, 'c
   --> clap-2.33.1/src/app/help.rs:453:5
    |
453 |     fn help<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>, spec_vals: &str) -> io::Result<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/help.rs:453:53
    |
453 |     fn help<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>, spec_vals: &str) -> io::Result<()> {
    |                                                     ^^

warning: the following explicit lifetimes could be elided: 'easy
    --> curl-0.4.44/src/easy/handle.rs:1402:5
     |
1402 |     pub fn transfer<'data, 'easy>(&'easy mut self) -> Transfer<'easy, 'data> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
help: replace with `'_` in generic arguments such as here
    --> curl-0.4.44/src/easy/handle.rs:1402:64
     |
1402 |     pub fn transfer<'data, 'easy>(&'easy mut self) -> Transfer<'easy, 'data> {
     |                                                                ^^^^^
     = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a, 'b
  --> clap-2.33.1/src/completions/elvish.rs:67:1
   |
67 | / fn generate_inner<'a, 'b, 'p>(
68 | |     p: &'p Parser<'a, 'b>,
69 | |     previous_command_name: &str,
70 | |     names: &mut Vec<&'p str>,
71 | | ) -> String {
   | |___________^
   |
help: replace with `'_` in generic arguments such as here
  --> clap-2.33.1/src/completions/elvish.rs:68:19
   |
68 |     p: &'p Parser<'a, 'b>,
   |                   ^^

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.143/src/ser.rs:869:1
    |
869 | / fn serialize_struct_variant<'a>(
870 | |     context: StructVariant<'a>,
871 | |     params: &Parameters,
872 | |     fields: &[Field],
873 | |     name: &str,
874 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.143/src/ser.rs:870:28
    |
870 |     context: StructVariant<'a>,
    |                            ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/cargo_compile.rs:297:1
    |
297 | / pub fn print<'a>(
298 | |     ws: &Workspace<'a>,
299 | |     options: &CompileOptions,
300 | |     print_opt_value: &str,
301 | | ) -> CargoResult<()> {
    | |____________________^
    |
help: replace with `'_` in generic arguments such as here
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/cargo_compile.rs:298:20
    |
298 |     ws: &Workspace<'a>,
    |                    ^^

warning: the following explicit lifetimes could be elided: 'b, 'c
   --> clap-2.33.1/src/app/help.rs:325:5
    |
325 |     fn val<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> Result<String, io::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/help.rs:325:52
    |
325 |     fn val<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> Result<String, io::Error> {
    |                                                    ^^

warning: the following explicit lifetimes could be elided: 'k
   --> hyper-0.10.16/src/server/mod.rs:432:5
    |
432 |     fn handle<'a, 'k>(&'a self, req: Request<'a, 'k>, res: Response<'a, Fresh>) {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> hyper-0.10.16/src/server/mod.rs:432:50
    |
432 |     fn handle<'a, 'k>(&'a self, req: Request<'a, 'k>, res: Response<'a, Fresh>) {
    |                                                  ^^

warning: the following explicit lifetimes could be elided: 's
   --> grep-printer-0.1.5/src/json.rs:465:5
    |
465 | /     pub fn sink<'s, M: Matcher>(
466 | |         &'s mut self,
467 | |         matcher: M,
468 | |     ) -> JSONSink<'static, 's, M, W> {
    | |____________________________________^
    |
help: replace with `'_` in generic arguments such as here
   --> grep-printer-0.1.5/src/json.rs:468:28
    |
468 |     ) -> JSONSink<'static, 's, M, W> {
    |                            ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> chrono-0.4.19/src/format/mod.rs:391:1
    |
391 | / pub fn format_item<'a>(
392 | |     w: &mut fmt::Formatter,
393 | |     date: Option<&NaiveDate>,
394 | |     time: Option<&NaiveTime>,
395 | |     off: Option<&(String, FixedOffset)>,
396 | |     item: &Item<'a>,
397 | | ) -> fmt::Result {
    | |________________^
    |
help: replace with `'_` in generic arguments such as here
   --> chrono-0.4.19/src/format/mod.rs:396:17
    |
396 |     item: &Item<'a>,
    |                 ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/tree/mod.rs:354:1
    |
354 | / fn print_dependencies<'a>(
355 | |     config: &Config,
356 | |     graph: &'a Graph<'_>,
357 | |     node_index: usize,
...   |
368 | |     kind: &EdgeKind,
369 | | ) {
    | |__^

warning: the following explicit lifetimes could be elided: 'a
   --> serde_derive-1.0.123/src/ser.rs:953:1
    |
953 | / fn serialize_struct_variant_with_flatten<'a>(
954 | |     context: StructVariant<'a>,
955 | |     params: &Parameters,
956 | |     fields: &[Field],
957 | |     name: &str,
958 | | ) -> Fragment {
    | |_____________^
    |
help: replace with `'_` in generic arguments such as here
   --> serde_derive-1.0.123/src/ser.rs:954:28
    |
954 |     context: StructVariant<'a>,
    |                            ^^

warning: the following explicit lifetimes could be elided: 's
   --> grep-printer-0.1.5/src/standard.rs:479:5
    |
479 | /     pub fn sink<'s, M: Matcher>(
480 | |         &'s mut self,
481 | |         matcher: M,
482 | |     ) -> StandardSink<'static, 's, M, W> {
    | |________________________________________^
    |
help: replace with `'_` in generic arguments such as here
   --> grep-printer-0.1.5/src/standard.rs:482:32
    |
482 |     ) -> StandardSink<'static, 's, M, W> {
    |                                ^^

warning: the following explicit lifetimes could be elided: 'b, 'c
   --> clap-2.33.1/src/app/help.rs:283:5
    |
283 |     fn short<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/help.rs:283:54
    |
283 |     fn short<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |                                                      ^^

warning: the following explicit lifetimes could be elided: 'b, 'c
   --> clap-2.33.1/src/app/help.rs:273:5
    |
273 |     fn write_arg<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: replace with `'_` in generic arguments such as here
   --> clap-2.33.1/src/app/help.rs:273:58
    |
273 |     fn write_arg<'b, 'c>(&mut self, arg: &ArgWithDisplay<'b, 'c>) -> io::Result<()> {
    |                                                          ^^
    = note: requested on the command line with `--force-warn clippy::needless-lifetimes`

warning: the following explicit lifetimes could be elided: 'a
   --> target/lintcheck/sources/cargo-0.64.0/src/cargo/ops/cargo_generate_lockfile.rs:164:5
    |
164 | /     fn fill_with_deps<'a>(
165 | |         resolve: &'a Resolve,
166 | |         dep: PackageId,
167 | |         set: &mut HashSet<PackageId>,
168 | |         visited: &mut HashSet<PackageId>,
169 | |     ) {
    | |______^

@smoelius
Copy link
Contributor Author

smoelius commented Nov 1, 2022

I'm unsure which false negative you mean with the first entry:

changelog: fix needless_borrow false negative

Ugh. Sorry, @xFrednet. It should be better now:

changelog: fix `needless_lifetimes` false negative involving functions with multiple unnamed lifetimes

@smoelius
Copy link
Contributor Author

smoelius commented Nov 1, 2022

Here's some added cases it lints to skim through, looks good to me

Thanks very much for this, @Alexendoo.

I changed those two <= to ==. So, provided the new the changelog entry is okay, I think I have addressed everything up to this point. But please let me know if I've missed something.

@Alexendoo
Copy link
Member

Yep, looks all good to me thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 1, 2022

📌 Commit c0d9285 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Nov 1, 2022

⌛ Testing commit c0d9285 with merge 7600535...

@bors
Copy link
Collaborator

bors commented Nov 1, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 7600535 to master...

@bors bors merged commit 7600535 into rust-lang:master Nov 1, 2022
@smoelius smoelius deleted the improve-needless-lifetimes branch November 1, 2022 01:11
@xFrednet
Copy link
Member

xFrednet commented Nov 1, 2022

Ugh. Sorry, @xFrednet. It should be better now:

Perfect, thank you very much @smoelius!

bors added a commit that referenced this pull request Nov 4, 2022
Update CONTRIBUTING.md with changelog guidance

`@xFrednet` I cribbed some text of yours from #9743 (comment) and did some light editing in the hope that others might find it.

r? `@xFrednet`

changelog: Update CONTRIBUTING.md with changelog guidance
@smoelius smoelius mentioned this pull request Nov 22, 2022
bors added a commit that referenced this pull request Nov 22, 2022
Use `walk_generic_arg`

This is a tiny followup to to #9743, now that rust-lang/rust#103692 has landed.

r? `@Alexendoo`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants