-
Notifications
You must be signed in to change notification settings - Fork 13.3k
structured suggestions for unused-lifetimes lint #54686
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the rightward-drift, looks awesome!
r=me if we pull out a helper function. Or @zackmdavis if for some reason that's hard, that's cool too.
match hir_item.node { | ||
hir::ItemKind::Fn(_, _, ref generics, _) | | ||
hir::ItemKind::Impl(_, _, _, ref generics, _, _, _) => { | ||
let unused_lt_span = if generics.params.len() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and maybe the code to get the unused_lt_span
would be a nice helper, too? it doesn't seem to use too many free variables
if let Some(parent_def_id) = self.tcx.parent(def_id) { | ||
if let Some(node_id) = self.tcx.hir.as_local_node_id(parent_def_id) { | ||
if let Some(Node::Item(hir_item)) = self.tcx.hir.find(node_id) { | ||
match hir_item.node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably pull this match
into a helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that similar code is elsewhere. I'm not against merging this, but we should probably sit down and look for duplication. I've written similar code in the past (although I can't find the right PR).
Also, I believe that get_generics
might allow you to reduce a bit of boilerplate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binding_suggestion
is a similar helper method. Maybe we should just have a single file with all of these helpers to avoid having to dig for them every time...
The same could be done for lifetimes used only once. |
Thanks to reviewers Tyler Mandry (for pointing out that this is ridiculous and we need a helper function), Niko Matsakis (for pointing out that the span-calculation code only has a couple free variables), and Esteban Küber (for pointing out `get_generics`).
Pulled out span calculation into a helper method and used @bors r=nikomatsakis |
📌 Commit efd7a31 has been approved by |
⌛ Testing commit efd7a31 with merge b5c33a424a250b7891b93f60e31d63c279cb66a3... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
🙄 😼 @bors retry |
structured suggestions for unused-lifetimes lint Regretfully, resolve_lifetime.rs is suffering from a bit of rightward-drift, but  r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Regretfully, resolve_lifetime.rs is suffering from a bit of rightward-drift, but
r? @nikomatsakis