Skip to content

refactor: apply clippy::non_canonical_partial_ord_impl#6909

Closed
shulaoda wants to merge 1 commit into
rust-lang:mainfrom
shulaoda:05-23-refactor_apply_clippy_non_canonical_partial_ord_impl
Closed

refactor: apply clippy::non_canonical_partial_ord_impl#6909
shulaoda wants to merge 1 commit into
rust-lang:mainfrom
shulaoda:05-23-refactor_apply_clippy_non_canonical_partial_ord_impl

Conversation

@shulaoda
Copy link
Copy Markdown
Contributor

Summary

  • In src/cargo-fmt/main.rs, reworks the manual PartialOrd for Target impl so partial_cmp is defined as Some(self.cmp(other)) rather than duplicating the self.path.cmp(&other.path) body that already lives in Ord::cmp.
  • Reorders the impl blocks so Ord precedes PartialOrd, matching the canonical pattern.
  • Addresses clippy::non_canonical_partial_ord_impl, run as a single-rule pass: cargo clippy -- -A clippy::all -W clippy::non_canonical_partial_ord_impl.

When a type implements both Ord and PartialOrd by hand, partial_cmp must agree with cmp. Routing partial_cmp through cmp removes the risk of the two impls drifting out of sync if the ordering logic is ever changed.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 22, 2026
@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented May 22, 2026

Going to close until we decide on which clippy lints we want to enforce in the codebase.

@ytmimi ytmimi closed this May 22, 2026
@rustbot rustbot removed the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants