-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Constify Eq, Ord, PartialOrd #144847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Constify Eq, Ord, PartialOrd #144847
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Squash this into one commit please @rustbot author |
Reminder, once the PR becomes ready for a review, use |
@rustbot ready |
Not a review but just a question as I don't know the contexts very well 😅 |
This comment has been minimized.
This comment has been minimized.
Fair enough, I've added |
Sorry for taking a long time to review this. I'm actually somewhat uncomfortable by the scope of this PR. Could you please limit the number of types that this adds const impls for to just types that seem relevant for const programming? Specifically, things like:
Don't seem really relevant here. I think this constification could probably just stick to constifying some impls for built-in types and other important types, and not just try to constify everything that can be constified in the standard library. Also, since this adds new bounds to things, let's run a perf test. @bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Constify Eq, Ord, PartialOrd
@rustbot author |
Note that regressions on the PR you linked was ultimately triaged at the rollup. Those negative perf results are due to making built-in traits const, which then increases the times where we have to check const conditions of traits, find implied predicates (super traits), etc. They're pretty much unavoidable, there's nothing much we can do, and we'll have to stick with it if we want libstd constified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some leftover syntax, otherwise lgtm
This PR was rebased onto a different master commit! Check out the changes with our |
@bors r+ |
@bors p=4 (rollup interleaving) |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Appears to be a legitimate codegen failure related to |
Ok. It is a legitimate codegen failure; I can reproduce it locally, including after rebase. I do not understand what is specifically wrong with the codegen (cc @scottmcm ), but the reason appears to be this change: I'm unsure why the difference between the while loop and the for loop results in incorrect codegen. I can revert this specific change for now (it doesn't give us slice rust/library/core/src/slice/cmp.rs Line 186 in f70c98f
) until we either figure out how to make the while loop work with codegen, or we can use for in const code (though if I understand correctly, this will require iterators, which by themselves will probably depend on this code).
|
☔ The latest upstream changes (presumably #145644) made this pull request unmergeable. Please resolve the merge conflicts. |
Ok I've pushed the version that drops the const-hack in slice code. cc @oli-obk |
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Since this was removed from the queue, could you also replace the references to the |
@bors p=0 No longer needed to thread between rollups, as the queue is back to normal now. |
Adds
#[const_trait]
and impls forEq
,Ord
,PartialOrd
. Impl for some other traits (e.g., slices and arrays) are blocked mainly on const closures (#106003).For TypeId Ord we need const pointer comparison (#53020)
Tracking issue #143800