rust-lang / rust-lang/rust-clippy
incomplete ordering trait impls lint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
When a user derives or implement PartialOrd<T> for T we can call it a day.
However, when a user implements PartialOrd<U> for T, then for transitivity ("a < b and b < c implies a < c") to hold the user needs to provide more trait implementations (proof below):
PartialOrd<T> for TPartialOrd<U> for UPartialOrd<T> for U
All these implementations need to "cooperate" and implement the same semantics for everything to work and I don't think we can check that, not statically at least. But we could at least check that they are provided.
Proof:
Consider: a: T, b: U, c: T
a < bis ok, sincePartialOrd<U> for Tis implemented,b < cdoes not type check unless the user also implementsPartialOrd<T> for U,a < cdoes not type check unless the user also implementsPartialOrd<T> for T,
Consider the opposite case: a: U, b: T, c: U where a < c requires PartialOrd<U> for U.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing Rust Clippy lint implementations and their tests, then trace how trait implementations are inspected. The intended result is a lint that detects a cross-type PartialOrd for T without the three related PartialOrd implementations described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100