Skip to content

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Aug 3, 2025

Adds #[const_trait] and impls for Eq, 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

@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 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

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

Squash this into one commit please

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 3, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Randl
Copy link
Contributor Author

Randl commented Aug 3, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 3, 2025
@ShoyuVanilla
Copy link
Member

Not a review but just a question as I don't know the contexts very well 😅
I guess PartialEq and Eq could be const impl'd on tuples as well?

@rust-log-analyzer

This comment has been minimized.

@Randl
Copy link
Contributor Author

Randl commented Aug 8, 2025

Fair enough, I've added impl const for tuples

@compiler-errors
Copy link
Member

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:

#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
pub struct AllocError;

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

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 14, 2025
Constify Eq, Ord, PartialOrd
@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 14, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 8, 2025
@npmccallum
Copy link
Contributor

@Randl I was just made aware of this PR. I have a parallel PR here #146097 that does a bunch of similar stuff. I'm happy to work together. The review of this PR seems further along than mine. So I'm also happy to just wait for your merge and then rebase and see what the differences are.

@rustbot
Copy link
Collaborator

rustbot commented Sep 12, 2025

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.

@Randl
Copy link
Contributor Author

Randl commented Sep 12, 2025

Sorry I pushed the wrong version
@oli-obk can you approve again please? should be good now

@oli-obk
Copy link
Contributor

oli-obk commented Sep 12, 2025

For TypeId Ord we need const pointer comparison (#53020)

TypeId ord is a special topic. I think we could special case it to internally compare the hash like at runtime, without exposing the actual value. Please open a dedicated issue for it so we can make a decision on whether to never allow it or whether to allow it by exposing the hash order

@oli-obk
Copy link
Contributor

oli-obk commented Sep 12, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 12, 2025

📌 Commit ff9b1c1 has been approved by oli-obk

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 12, 2025
@bors
Copy link
Collaborator

bors commented Sep 12, 2025

⌛ Testing commit ff9b1c1 with merge 5c11fb8...

@bors
Copy link
Collaborator

bors commented Sep 12, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 5c11fb8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 12, 2025
@bors bors merged commit 5c11fb8 into rust-lang:master Sep 12, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 12, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing a171994 (parent) -> 5c11fb8 (this PR)

Test differences

Show 2632 test diffs

2632 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 5c11fb842afc9876e985886c30292a227caee632 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 4050.5s -> 3223.3s (-20.4%)
  2. x86_64-gnu-llvm-19-1: 3977.3s -> 3289.0s (-17.3%)
  3. dist-aarch64-windows-gnullvm: 4589.0s -> 5104.9s (11.2%)
  4. i686-gnu-nopt-1: 8168.3s -> 7291.0s (-10.7%)
  5. aarch64-gnu-debug: 4183.8s -> 3774.5s (-9.8%)
  6. dist-aarch64-apple: 7628.6s -> 8342.4s (9.4%)
  7. i686-gnu-2: 5975.8s -> 5435.2s (-9.0%)
  8. i686-gnu-1: 8067.7s -> 7394.2s (-8.3%)
  9. aarch64-apple: 6753.5s -> 6260.8s (-7.3%)
  10. x86_64-gnu-llvm-20-2: 5895.7s -> 5475.5s (-7.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5c11fb8): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 1
Regressions ❌
(secondary)
0.1% [0.1%, 0.3%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.1%] 2
All ❌✅ (primary) 0.1% [0.1%, 0.1%] 1

Max RSS (memory usage)

Results (primary 2.4%, secondary 3.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
3.3% [1.7%, 4.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.518s -> 468.518s (-0.21%)
Artifact size: 388.08 MiB -> 388.10 MiB (0.01%)

@theemathas
Copy link
Contributor

Are there supposed to be an impl const AlwaysApplicableOrd somewhere? I can't find any.

@npmccallum
Copy link
Contributor

Are there supposed to be an impl const AlwaysApplicableOrd somewhere? I can't find any.

It is in my PR (linked above). I'm currently rebasing in top of this merge.

@panstromek
Copy link
Contributor

perf triage:

Slight regression in doc benchmarks, similar to pre-merge results. Expected because of more const handling (looks like more time is spent in const related queries from brief look at the detailed results of hellp-world: https://perf.rust-lang.org/detailed-query.html?commit=5c11fb842afc9876e985886c30292a227caee632&benchmark=helloworld-doc&scenario=full&base_commit=a171994070dc18c3a32fc1aa2d98cf03ae96b63e)

Justified by #144847 (comment), if I understand correctly.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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.