8000 add `[const] PartialEq` bound to `PartialOrd` by npmccallum · Pull Request #146690 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Conversation

npmccallum
Copy link
Contributor

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It is, rather, logical: anything which is orderable should by definition have equality. Is the same true for constness? Should every type which is const orderable also have const equality?

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It
is, rather, logical: anything which is orderable should by
definition have equality. Is the same true for constness? Should
every type which is const orderable also have const equality?
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 17, 2025
@rustbot
Copy link
Collaborator
rustbot commented Sep 17, 2025

r? @tgross35

rustbot has assigned @tgross35.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@tgross35
Copy link
Contributor

I don't have a great answer, but I think this makes sense. If nothing else, it seems more usable: having a type that is const PartialOrd but non-const PartialEq doesn't make much sense, so not needing to worry about this combination should make bounds a bit easier.

Cc @rust-lang/wg-const-eval for thoughts.

@lcnr
Copy link
Contributor
lcnr commented Sep 19, 2025

we do not elaborate trait const Trait: Super to const Super 🤔 that feels footgunny to me

without being involved in any of the design here, i would expect at least a lint that super traits also have to maybe-const for const sub-traits

@tgross35
Copy link
Contributor

without being involved in any of the design here, i would expect at least a lint that super traits also have to maybe-const for const sub-traits

This sounds like something that would be helpful. Perhaps just not in cases where the super trait doesn't have any functions, e.g.:

pub trait A {
    const FOO: u32 = 10;
}

pub const trait B: A {
    fn foo() -> u32 { Self::FOO }
}

In any case, the change here seems reasonable and looks like it got some 👍 from relevant people, so

@bors r+ rollup

@bors
Copy link
Collaborator
bors commented Sep 19, 2025

📌 Commit 8d7ec96 has been approved by tgross35

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 19, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 19, 2025
add `[const] PartialEq` bound to `PartialOrd`

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It is, rather, logical: anything which is orderable should by definition have equality. Is the same true for constness? Should every type which is const orderable also have const equality?
bors added a commit that referenced this pull request Sep 19, 2025
Rollup of 5 pull requests

Successful merges:

 - #146690 (add `[const] PartialEq` bound to `PartialOrd`)
 - #146776 (fixes for numerous clippy warnings)
 - #146777 (fix ./x readdir logic when CDPATH is set)
 - #146781 (mbe: Fix feature gate for `macro_derive`)
 - #146785 (btree: safety comments for init and new)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 96a4ae3 into rust-lang:master Sep 20, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 20, 2025
rust-timer added a commit that referenced this pull request Sep 20, 2025
Rollup merge of #146690 - npmccallum:convo, r=tgross35

add `[const] PartialEq` bound to `PartialOrd`

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It is, rather, logical: anything which is orderable should by definition have equality. Is the same true for constness? Should every type which is const orderable also have const equality?
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
add `[const] PartialEq` bound to `PartialOrd`

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It is, rather, logical: anything which is orderable should by definition have equality. Is the same true for constness? Should every type which is const orderable also have const equality?
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#146690 (add `[const] PartialEq` bound to `PartialOrd`)
 - rust-lang#146776 (fixes for numerous clippy warnings)
 - rust-lang#146777 (fix ./x readdir logic when CDPATH is set)
 - rust-lang#146781 (mbe: Fix feature gate for `macro_derive`)
 - rust-lang#146785 (btree: safety comments for init and new)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Oct 9, 2025
add `[const] PartialEq` bound to `PartialOrd`

This change is included for discussion purposes.

The PartialOrd bound on PartialEq is not strictly necessary. It is, rather, logical: anything which is orderable should by definition have equality. Is the same true for constness? Should every type which is const orderable also have const equality?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0