-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add check on redundant _ variables in structs #482
Conversation
@@ -115,6 +118,11 @@ fn check_pat(cx: &LateContext, pat: &Pat, init: &Option<&Expr>, span: Span, | |||
} | |||
} else { | |||
for field in pfields { | |||
if pfields.len() > 0 && pprust::pat_to_string(&*field.node.pat) == "_" { |
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.
You dont need pprust here; just check if its a PatWild
I would prefer if this were in its own file (pat.rs?) as an EarlyLintPass. Remember to register the pass in lib.rs! |
I updated and added a more precise check. What do you think of it? PS: it seems to break build because rut-clippy source code has issues like this in the code... |
A good idea would be to give a hint what the pattern would look like, which should be possible using |
@llogiq: This is a bit problematic because changing it seems to break. If we remove one field, it breaks because it says "[field] isn't bound". |
Have you added |
@@ -15,7 +15,7 @@ declare_lint!(pub SHADOW_REUSE, Allow, | |||
"rebinding a name to an expression that re-uses the original value, e.g. \ | |||
`let x = x + 1`"); | |||
declare_lint!(pub SHADOW_UNRELATED, Allow, | |||
"The name is re-bound without even using the original value"); | |||
"The name is re-bound without even using the original value"); |
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.
Does that single space change anything about the code? Otherwise I think we may remove it from the change to reduce diff clutter. 😄
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.
Oups. :p
@llogiq: I did, but I must have made a mistake somewhere else. Code updated. |
|
||
use utils::span_lint; | ||
|
||
declare_lint!(pub UNNEEDED_BINDING, Warn, |
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.
Should be only one lint, unneeded_bindings. The actual message can be tweaked to handle plurals, but we don't want to create two lints for plurality.
dogfood failure
|
cc #479
This is just preview. I need help on some point:
Thanks in advance for your help. :)