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
fix incorrect suggestion for !(a as type >= b)
#12626
fix incorrect suggestion for !(a as type >= b)
#12626
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @blyxyas (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Something I don't know how to check is whether this also works for |
Ok, I made some comments earlier which I then thought was wrong, so I panic and deleted it, so... sorry about that. what I was saying is, the |
c3e85f3
to
38dbb0b
Compare
thanks, fixed now! |
38dbb0b
to
986ebb7
Compare
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.
meow meow meow
clippy_lints/src/booleans.rs
Outdated
if let (ExprKind::Cast(..), BinOpKind::Ge) = (&lhs.kind, binop.node) { | ||
if !(lhs_snippet.starts_with('(') && lhs_snippet.ends_with(')')) { |
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.
Could you swap the order of these two so that the rare condition is processed earlier? (Performance meow meow)
Also, does this need to check for casts and >=? Are these the only variables where the suggestion is incorrect?
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.
Could you swap the order of these two so that the rare condition is processed earlier? (Performance meow meow)
done
Also, does this need to check for casts and >=? Are these the only variables where the suggestion is incorrect?
no, <=
is parsed as a single token, and is never seen as the start of a sequence of generic arguments. I believe <
is the only operation where the naive transformation produces a result that does not parse.
986ebb7
to
6a2cb33
Compare
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.
LGTM, thanks! ❤️
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #12625
The expression
!(a as type >= b)
got simplified toa as type < b
, but because of rust's parsing rules that<
is interpreted as a start of generic arguments fortype
. This is fixed by recognizing this case and adding extra parens around the left-hand side of the comparison.changelog: [
nonminimal_bool
]: fix incorrect suggestion for!(a as type >= b)