Do not lint when the two differing identifiers in a suspicious grouping#17177
Do not lint when the two differing identifiers in a suspicious grouping#17177durationextender wants to merge 1 commit into
Conversation
are explicitly compared with a relational operator elsewhere in the same expression, as this proves the use of different variables was intentional this fixes 17143
|
r? @Jarcho rustbot has assigned @Jarcho. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@rustbot ready |
|
I don't really want to have changes to this lint without having a good description of what it should and shouldn't catch. This includes both an abstract description that can be used to judge specific cases and a sizable set of specific cases. For this PR you look to be really special casing the particular issue, but it's not clear |
this does make sense to me, maybe i should have considered that when writing the issue |
When
f(x) && g(y) && x != yis written, the presence ofx != yproves the programmer intentionally used different variables. The lint
was incorrectly suggesting
f(x) && g(x)as a fix.Before emitting the suggestion, we now scan the rest of the binary op
chain for any comparison operator (
!=,==,<,>,<=,>=)that contains both of the differing identifiers. If found, the lint is
suppressed.
fixes #17143
changelog: [
suspicious_operation_groupings]: do not lint when the differing identifiers are explicitly compared elsewhere in the same expressionprobably a better way of handling this, but i couldnt figure out how to do it better performance/idiomatic and logic wise, sorry.