Skip to content

Conversation

@camelid
Copy link
Member

@camelid camelid commented Apr 8, 2025

tracking issue: #132980
fixes #131046
fixes #134641

As part of implementing min_generic_const_args, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like N or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the #[type_const] attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new ConstItemRhs enum in the HIR, and a similar but simpler enum in the AST. When #[type_const] is not applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a hir::ConstArg. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using AnonConsts. Then in generics_of, we can take advantage of the existing machinery to bar the AnonConst rhs's from using parent generics.

@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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 8, 2025
@camelid camelid 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 Apr 8, 2025
@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the mgca-const-items branch from fa42f86 to 6054bd5 Compare April 9, 2025 16:14
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the mgca-const-items branch from 4f6c9ab to a46aa4c Compare May 15, 2025 12:37
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label May 15, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@camelid camelid added A-const-generics Area: const generics (parameters and arguments) F-min_generic_const_args `#![feature(min_generic_const_args)]` labels May 17, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 21, 2025

☔ The latest upstream changes (presumably #141343) made this pull request unmergeable. Please resolve the merge conflicts.

@BoxyUwU
Copy link
Member

BoxyUwU commented May 23, 2025

@oli-obk I've assigned you to this PR alongside me because I'd definitely want you to review it before it lands since its so CTFE involved 🤔 I don't think it needs reviewing rn though, things are so up in the air and we're not bootstrapping yet :3

When mgca is enabled, const rhs's that are paths may have false
negatives with the lints in non_copy_const.rs. But these should probably
be using the trait solver anyway, and it only happens under mgca.
Also removed a test that was literally a duplicate of the one I kept.
@camelid
Copy link
Member Author

camelid commented Nov 8, 2025

@bors r=oli-obk,BoxyUwU rollup=never

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

📌 Commit 45391bd has been approved by oli-obk,BoxyUwU

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 Nov 8, 2025
@camelid
Copy link
Member Author

camelid commented Nov 8, 2025

@BoxyUwU thanks so much for working with me on this throughout the whole process! And @oli-obk thanks for reviewing!

@bors
Copy link
Collaborator

bors commented Nov 8, 2025

⌛ Testing commit 45391bd with merge 72b21e1...

@bors
Copy link
Collaborator

bors commented Nov 9, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk,BoxyUwU
Pushing 72b21e1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 9, 2025
@bors bors merged commit 72b21e1 into rust-lang:master Nov 9, 2025
12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2025

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 fb23dd3 (parent) -> 72b21e1 (this PR)

Test differences

Show 316 test diffs

Stage 1

  • [crashes] tests/crashes/127643.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/131046.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/131406.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/134641.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/mgca/ace-with-const-ctor.rs: [missing] -> pass (J0)
  • [crashes] tests/crashes/mgca/type_const-only-in-trait.rs: [missing] -> pass (J0)
  • [rustdoc] tests/rustdoc/constant/ice-associated-const-equality-105952.rs: pass -> [missing] (J0)
  • [ui] tests/rustdoc-ui/invalid_associated_const.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/associated_const_equality/coherence.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/associated_const_equality/mismatched-types-with-generic-in-ace-no-feature-gate.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/associated_const_equality/mismatched-types-with-generic-in-ace.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/type_const-only-in-impl.rs: [missing] -> pass (J0)

Stage 2

  • [crashes] tests/crashes/127643.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/131046.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/131406.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/134641.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/mgca/ace-with-const-ctor.rs: [missing] -> pass (J1)
  • [crashes] tests/crashes/mgca/type_const-only-in-trait.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/associated_const_equality/coherence.rs: [missing] -> pass (J2)
  • [ui] tests/ui/const-generics/associated_const_equality/mismatched-types-with-generic-in-ace-no-feature-gate.rs: [missing] -> pass (J2)
  • [ui] tests/ui/const-generics/associated_const_equality/mismatched-types-with-generic-in-ace.rs: [missing] -> pass (J2)
  • [ui] tests/ui/const-generics/mgca/type_const-only-in-impl.rs: [missing] -> pass (J2)
  • [rustdoc] tests/rustdoc/constant/ice-associated-const-equality-105952.rs: pass -> [missing] (J3)
  • [ui] tests/rustdoc-ui/invalid_associated_const.rs: pass -> [missing] (J3)

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

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 72b21e1a64dbbbb3b59ac7ce21363c366a894b79 --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. pr-check-1: 1471.0s -> 1863.4s (+26.7%)
  2. x86_64-rust-for-linux: 2487.5s -> 3149.5s (+26.6%)
  3. x86_64-gnu-miri: 4051.6s -> 4969.3s (+22.7%)
  4. x86_64-gnu-gcc: 2888.3s -> 3512.3s (+21.6%)
  5. dist-aarch64-apple: 7970.3s -> 6351.1s (-20.3%)
  6. aarch64-apple: 8085.7s -> 9388.6s (+16.1%)
  7. i686-gnu-2: 5722.6s -> 6477.8s (+13.2%)
  8. armhf-gnu: 5069.5s -> 5677.7s (+12.0%)
  9. i686-gnu-nopt-1: 7461.5s -> 8305.8s (+11.3%)
  10. x86_64-gnu-llvm-20-1: 3391.8s -> 3769.9s (+11.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 (72b21e1): comparison URL.

Overall result: ❌ regressions - 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.2% [0.1%, 0.5%] 24
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.5%] 24

Max RSS (memory usage)

Results (primary -2.5%)

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.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Cycles

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

Binary size

Results (secondary 0.0%)

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.0% [0.0%, 0.0%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 476.932s -> 476.758s (-0.04%)
Artifact size: 390.92 MiB -> 390.96 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-const-generics Area: const generics (parameters and arguments) F-min_generic_const_args `#![feature(min_generic_const_args)]` 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-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: Associated const projection not yet supported access outside the bounds for given AllocRange

7 participants