-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adds inequality cases to bool comparison (#3438) #3473
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
Adds inequality cases to bool comparison (#3438) #3473
Conversation
clippy_lints/src/needless_bool.rs
Outdated
| } | ||
| } else if let ExprKind::Binary( | ||
| Spanned { | ||
| node: BinOpKind::Ne, .. |
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.
since the only difference is the type of operation and some error messages, can you try to deduplicate this code with the above code? Mayne by moving it out into a function
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 was thinking, considering the difference in suggesting !hint or hint, on passing a closure (Fn(Sugg) -> Sugg) such as |hint| !hint.
Do you think there is a more idiomatic way of doing this?
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.
Do you think there is a more idiomatic way of doing this?
Nope, that sounds good to me if that solves all the duplication.
31cfea5 to
3964b08
Compare
clippy_lints/src/needless_bool.rs
Outdated
| e: &'tcx Expr, | ||
| true_message: &str, | ||
| false_message: &str, | ||
| true_hint: F, |
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.
just a nit: remove the generic parameters and replace their uses in the argument list with impl FnOnce(Sugg<'_>) -> Sugg<'_>
|
r=me with nit fixed |
The lint now checks cases like `y != true`
3964b08 to
3930148
Compare
|
LGTM, thanks! |
The lint now checks cases like
y != true, as suggested by the issue #3438.Other cases talked about in the issue (i.e.
x < yvs!x && y) are not implemented by this PR.I can do so if you prefer that the whole issue is closed at once but I might need a little guidance (I will give it a try meanwhile).
Please let me know of any changes necessary