Skip to content

Conversation

npmccallum
Copy link
Contributor

@npmccallum npmccallum commented Sep 1, 2025

Related to: #143800
Requires (includes): #146088
Requires (not included): #146089

Also constify the impls of basic types.

One potentially controversial part of this change is making Eq, a
marker trait, const. I chose to do this ease user adoption.
Otherwise, code which already has an Eq bound and uses it to
proxy a PartialEq bound would need to add a separate bound. This
would cause a litering of bounds in downstream types.

I also chose to inline default_chaining_impl() since this avoids
making the core comparison constness depend on const closures.
The code duplication is minimal.
This currently involves manually inlining chaining_impl() to
avoid a dependency on const closures.
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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

@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 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 /// Trait for comparisons using the equality operator.
 ///
Diff in /checkout/library/core/src/cmp.rs:337:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_diagnostic_item = "Eq"]
 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
-pub const trait Eq: [const] PartialEq<Self> + PointeeSized {
+const pub trait Eq: [const] PartialEq<Self> + PointeeSized {
     // this method is used solely by `impl Eq or #[derive(Eq)]` to assert that every component of a
     // type implements `Eq` itself. The current deriving infrastructure means doing this assertion
     // without using a method on this trait is nearly impossible.
Diff in /checkout/library/core/src/cmp.rs:964:
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_diagnostic_item = "Ord"]
 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
-pub const trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
+const pub trait Ord: [const] Eq + [const] PartialOrd<Self> + PointeeSized {
     /// This method returns an [`Ordering`] between `self` and `other`.
     ///
     /// By convention, `self.cmp(&other)` returns the ordering matching the expression
Diff in /checkout/library/core/src/cmp.rs:1349:
 #[rustc_diagnostic_item = "PartialOrd"]
 #[allow(multiple_supertrait_upcastable)] // FIXME(sized_hierarchy): remove this
 #[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
-pub const trait PartialOrd<Rhs: PointeeSized = Self>: [const] PartialEq<Rhs> + PointeeSized {
+const pub trait PartialOrd<Rhs: PointeeSized = Self>:
+    [const] PartialEq<Rhs> + PointeeSized
+{
     /// This method returns an ordering between `self` and `other` values if one exists.
     ///
     /// # Examples
fmt: checked 6349 files

@oli-obk
Copy link
Contributor

oli-obk commented Sep 1, 2025

Oh no. What did I do with rustfmt. const pub trait Foo is funny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants