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

Extend needless_lifetimes to suggest eliding impl lifetimes #2

Closed
wants to merge 6 commits into from

Conversation

smoelius
Copy link
Owner

Example:

error: the following explicit lifetimes could be elided: 'a
  --> tests/ui/needless_lifetimes.rs:332:10
   |
LL |     impl<'a> Foo for Baz<'a> {}
   |          ^^              ^^
   |
help: elide the lifetimes
   |
LL -     impl<'a> Foo for Baz<'a> {}
LL +     impl Foo for Baz<'_> {}

The main change is in how impl lifetime uses are tracked. Previously, a hashmap was created, and lifetimes were removed from the hashmap as their uses were discovered. However, the uses are needed to generate elision suggestions. So, now, uses are added to the hashmap as they are discovered.

The PR is currently organized as six commits, which I think are self-explanatory:

  • Extend needless_lifetimes to suggest eliding impl lifetimes
  • Reorder functions [not strictly necessary, but IMHO, the code is better structured as a result]
  • Fix lifetime tests
  • Fix non-lifetime tests
  • Fix clippy_lints and clippy_utils
  • Fix typo in needless_lifetimes test

r? @Alexendoo (I think you are needless_lifetimes' primary author? Sorry if I have this wrong.)


changelog: Extend needless_lifetimes to suggest eliding impl lifetimes

@smoelius smoelius closed this Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant