Skip to content

Conversation

@saethlin
Copy link
Member

@saethlin saethlin commented Oct 27, 2025

This is an expansion of #148040.

The previous implementation only accepted trivial consts that assign a literal. For example:

const A: usize = 0;
const B: usize = A;

Before this PR, only A was a trivial const. Now B is too.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 27, 2025
@saethlin
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 27, 2025
Accept trivial consts based on trivial consts
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 27, 2025
@rust-bors

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Oct 27, 2025

☀️ Try build successful (CI)
Build commit: 2f43088 (2f430888c54e6073a1742439ac5020b07745922b, parent: 9ea8d67cc60e88ad6fffbf299a454c44227e001c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2f43088): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

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
Regressions ❌
(secondary)
0.4% [0.1%, 0.9%] 3
Improvements ✅
(primary)
-0.7% [-1.1%, -0.2%] 13
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.7% [-1.1%, -0.2%] 13

Max RSS (memory usage)

Results (primary 0.5%)

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

mean range count
Regressions ❌
(primary)
2.0% [0.6%, 3.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [-2.4%, 3.3%] 3

Cycles

Results (primary -4.4%, secondary -2.1%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.6% [1.6%, 1.6%] 1
Improvements ✅
(primary)
-4.4% [-5.1%, -3.6%] 2
Improvements ✅
(secondary)
-5.8% [-5.8%, -5.8%] 1
All ❌✅ (primary) -4.4% [-5.1%, -3.6%] 2

Binary size

Results (primary -0.3%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 2
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 2
Improvements ✅
(primary)
-0.4% [-0.6%, -0.0%] 16
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.0%] 2
All ❌✅ (primary) -0.3% [-0.6%, 0.0%] 18

Bootstrap: 474.628s -> 474.127s (-0.11%)
Artifact size: 390.61 MiB -> 390.58 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Oct 27, 2025
tcx.trivial_const(def)
}
Const::Val(v, ty) => Some((v, ty)),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the query just return c.const_ in general?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would callers do with Const::Ty and Const::Unevaluated?

@saethlin saethlin marked this pull request as ready for review October 28, 2025 03:46
@rustbot
Copy link
Collaborator

rustbot commented Oct 28, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the CTFE / Miri interpreter

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

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

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

rustbot commented Oct 28, 2025

r? @eholk

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

@eholk
Copy link
Contributor

eholk commented Oct 28, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 28, 2025

📌 Commit 9cbfbb1 has been approved by eholk

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

bors commented Oct 28, 2025

⌛ Testing commit 9cbfbb1 with merge 044d68c...

@bors
Copy link
Collaborator

bors commented Oct 29, 2025

☀️ Test successful - checks-actions
Approved by: eholk
Pushing 044d68c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 29, 2025
@bors bors merged commit 044d68c into rust-lang:master Oct 29, 2025
13 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Oct 29, 2025
@github-actions
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 278a909 (parent) -> 044d68c (this PR)

Test differences

Show 8 test diffs

8 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 044d68c3cb6a0b893b18293fa7f5719119403215 --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: 4159.4s -> 2986.2s (-28.2%)
  2. pr-check-1: 1934.5s -> 1564.7s (-19.1%)
  3. dist-aarch64-apple: 7564.8s -> 6393.5s (-15.5%)
  4. aarch64-gnu-debug: 4142.3s -> 4613.0s (11.4%)
  5. dist-powerpc-linux: 5524.7s -> 5049.2s (-8.6%)
  6. aarch64-apple: 9692.6s -> 8900.4s (-8.2%)
  7. dist-i686-mingw: 10055.3s -> 9271.7s (-7.8%)
  8. x86_64-msvc-2: 7028.8s -> 6482.2s (-7.8%)
  9. dist-aarch64-msvc: 6239.4s -> 5783.6s (-7.3%)
  10. x86_64-gnu-gcc: 3174.4s -> 3405.6s (7.3%)
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 (044d68c): 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
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 2
Improvements ✅
(primary)
-0.7% [-1.1%, -0.2%] 13
Improvements ✅
(secondary)
-1.4% [-1.4%, -1.4%] 1
All ❌✅ (primary) -0.7% [-1.1%, -0.2%] 13

Max RSS (memory usage)

Results (secondary -3.9%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.9% [-3.9%, -3.8%] 2
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.6%, secondary -5.7%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.6% [-3.1%, -2.1%] 2
Improvements ✅
(secondary)
-5.7% [-5.7%, -5.7%] 1
All ❌✅ (primary) -2.6% [-3.1%, -2.1%] 2

Binary size

Results (primary -0.3%, secondary -0.1%)

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

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 2
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 2
Improvements ✅
(primary)
-0.4% [-0.6%, -0.0%] 16
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) -0.3% [-0.6%, 0.0%] 18

Bootstrap: 474.493s -> 474.307s (-0.04%)
Artifact size: 390.04 MiB -> 390.07 MiB (0.01%)

@saethlin saethlin deleted the trivial-consts-recursive branch October 29, 2025 05:21
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. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants