-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fire clippy::op_ref on PartialOrd but !Ord types #4876
Conversation
CI failure is an extra lint trigger:
Context: rust-clippy/tests/ui/op_ref.rs Lines 17 to 22 in 7a943a9
Relevant arm: rust-clippy/clippy_lints/src/eq_op.rs Lines 163 to 180 in 7a943a9
Removing the ref here is wrong due to not having |
The "FP" is the same as #2597, it is not really a FP tough. In such a case the correct suggestion would be to write |
rust-lang/rust#66941 has been merged and this patch is now required to get clippy building with latest rust again. Should I just change the test expected output and mark it as a case of #2597? I'm honestly not certain how best to go about fixing that issue (and fixing it in this PR is probably outside of scope). |
I'm on this myself (there was also another PR, that broke Clippy). It stopped linting for this case, which is good (?). But it's weird, that it returned |
Note that |
Some context: this appears to be the only usage of
.ord_trait()
in the compiler. I've a PR that tries to remove it. It's definitely not correct here, though! Example:On the above snippet,
clippy::op_ref
does not fire unless we also deriveOrd
due to the use of.ord_trait()
here meaning we gate the lint on implementingOrd
, rather than justPartialOrd
which is the trait actually required to use comparison operators.changelog: Fix: trigger
clippy::op_ref
(needlessly taken reference of both operands) when a comparison operator's operands implementPartialOrd
but notOrd
. Previously, the lint only fired if and only ifOrd
was implemented.