`non_canonical_partial_ord_impl` is overzealous for trivial impls
Summary
I have a ZST where I'm manually implementing PartialOrd and Ord to remove some trait bounds. However, it warns that inlining the trivial Equal result as Some(Equal) in the PartialOrd impl is non-canonical.
I think that in this particular case, we can loosen the lint a bit. Calling the method is overkill and can increase the amount of generated code.
Lint Name
non_canonical_partial_ord_impl
Reproducer
This should not trigger the lint:
use core::cmp;
pub struct Test;
impl PartialOrd for Test {
fn partial_cmp(&self, _: &Self) -> Option<cmp::Ordering> {
Some(cmp::Ordering::Equal)
}
}
impl Ord for Test {
fn cmp(&self, _: &Self) -> cmp::Ordering {
cmp::Ordering::Equal
}
}
Version
clippy 0.1.94 (2850ca8295 2026-01-13)
Additional Labels
No response
This is neither a bug nor a false positive, but a request for enhancement.
@rustbot label -C-bug -I-false-positive +C-enhancement
I labelled it as a false positive because it's a request to make a lint not fire when it currently is, but sure, we can call it an enhancement too. The specific label here doesn't matter.
@rustbot claim
Hi @samueltardieu! I’ve recently submitted a PR for a Clippy good-first-issue improving a lint, and I’d be interested in working on this enhancement as well.
@rustbot claim