Skip to content

MGCA: Syntactically distinguish anon const const args - #149136

Merged
bors merged 1 commit into
rust-lang:mainfrom
BoxyUwU:mgca_explicit_anon_consts
Dec 13, 2025
Merged

MGCA: Syntactically distinguish anon const const args#149136
bors merged 1 commit into
rust-lang:mainfrom
BoxyUwU:mgca_explicit_anon_consts

Conversation

@BoxyUwU

@BoxyUwUBoxyUwU commented Nov 20, 2025

Copy link
Copy Markdown
Member

r? oli-obk

tracking issue: #132980

This PR requires that when feature(min_generic_const_args) is enabled, anon const const args are syntactically distinguishable from other kinds of args. We use const { ... } in const argument position to denote an anon const:

#![feature(min_generic_const_args)]// no longer allowed as `1 + 1` is represented via an anon const and// there is no syntactic markertypeFoo = [();1 + 1];// allowed, `const { ... }` indicates an anon const representationtypeFoo = [();const{1 + 1}];

This restriction is only placed when mgca is enabled. There should be no effect on stable. This restriction is not enforced for unbraced literals which we continue to implicitly wrap in an anon const: tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs

This restriction allows us to create DefIds for anon consts only when actually required. When it is syntactically ambiguous whether a const argument is an anon const or not we are forced to conservatively create a DefId for every const argument even if it doesn't wind up needing one.

This works fine on stable but under mgca we can wind up with anon consts nested inside non-anon-const const arguments resulting in a broken DefId tree. See #148838 where an anon const arg inside of a path arg winds up with a parent of a conservatively created DefId that doesn't actually correspond to an anon const, resulting in an ICE.

With #149114 every field initialiser in a const argument would become a place where there could possibly be an anon const. This would also get worse once we support tuple constructors- now every function argument is a place where there could possibly be an anon const.

We introduce this restriction to avoid creating massive amounts of unused DefIds that make the parent tree significantly more complicated, and to avoid having to paper over this issue in things like generics_of.

Fixes#148838

It also must be syntactically clear from context whether '_ means an inference lifetime or an elided lifetime parameter. This restriction will allow us to properly resolve '_ in const arguments in mgca. This PR doesn't actually fix handle this, but we could do so trivially after this lands.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs

cc @ZuseZ4

@rustbotrustbot 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Nov 20, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

Comment threadcompiler/rustc_ast_lowering/src/lib.rs
@BoxyUwU
BoxyUwUforce-pushed the mgca_explicit_anon_consts branch 2 times, most recently from a786e30 to 09d75e3CompareNovember 21, 2025 01:38
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
BoxyUwUforce-pushed the mgca_explicit_anon_consts branch from 09d75e3 to 5c64af2CompareNovember 21, 2025 03:53
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbotrustbot added the T-clippy Relevant to the Clippy team. label Nov 21, 2025
@bors

bors commented Nov 27, 2025

Copy link
Copy Markdown
Collaborator

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

@BoxyUwUBoxyUwU mentioned this pull request Nov 29, 2025
7 tasks
Comment threadcompiler/rustc_ast_lowering/src/lib.rs Outdated
Comment threadcompiler/rustc_ast_lowering/src/lib.rs
Comment threadcompiler/rustc_parse/src/parser/expr.rs Outdated
Comment threadsrc/tools/clippy/tests/ui/trait_duplication_in_bounds_assoc_const_eq.fixed Outdated
@rustbotrustbot 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 Dec 9, 2025
@BoxyUwU
BoxyUwUforce-pushed the mgca_explicit_anon_consts branch from 5c64af2 to 8f74277CompareDecember 10, 2025 07:46
@rustbot

This comment has been minimized.

@BoxyUwUBoxyUwU removed the T-clippy Relevant to the Clippy team. label Dec 10, 2025
Comment threadtests/ui/const-generics/associated_const_equality/coherence.rs Outdated
@oli-obk

Copy link
Copy Markdown
Contributor

r=me with commits cleaned up

@BoxyUwU
BoxyUwUforce-pushed the mgca_explicit_anon_consts branch from 8f74277 to 0c86a41CompareDecember 10, 2025 16:25
@BoxyUwU

Copy link
Copy Markdown
MemberAuthor

@bors r=oli-obk rollup=never

@bors

bors commented Dec 10, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 0c86a41 has been approved by oli-obk

It is now in the queue for this repository.

@borsbors removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Dec 10, 2025
@bors

bors commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit acc3a0e has been approved by oli-obk

It is now in the queue for this repository.

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 12, 2025
@BoxyUwU

Copy link
Copy Markdown
MemberAuthor

@bors r-

actually should wait for CI to pass given rebase

@borsbors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 12, 2025
@BoxyUwU

Copy link
Copy Markdown
MemberAuthor

@bors r=oli-obk

@bors

bors commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit acc3a0e has been approved by oli-obk

It is now in the queue for this repository.

@borsbors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 12, 2025
@bors

bors commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator

⌛ Testing commit acc3a0e with merge dc47a69...

@bors

bors commented Dec 13, 2025

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing dc47a69 to main...

@borsbors added the merged-by-bors This PR was explicitly merged by bors. label Dec 13, 2025
@bors
bors merged commit dc47a69 into rust-lang:mainDec 13, 2025
12 checks passed
@rustbotrustbot added this to the 1.94.0 milestone Dec 13, 2025
@github-actions

Copy link
Copy Markdown
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 fa5eda1 (parent) -> dc47a69 (this PR)

Test differences

Show 56 test diffs

Stage 1

  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs: [missing] -> pass (J1)
  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs#gce: pass -> [missing] (J1)
  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs#stock: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs: [missing] -> pass (J0)
  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs#gce: pass -> [missing] (J0)
  • [ui] tests/ui/associated-type-bounds/const-projection-err.rs#stock: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts_literals_hack.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/multi_braced_direct_const_args.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/unbraced_const_block_const_arg_gated.rs: [missing] -> pass (J0)

Additionally, 42 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 dc47a69ed94bc88b10b7d500cceacf29b87bcbbe --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. x86_64-gnu-llvm-21-1: 3238.0s -> 3753.9s (+15.9%)
  2. aarch64-gnu-llvm-20-2: 2251.0s -> 2580.7s (+14.6%)
  3. aarch64-gnu-llvm-20-1: 3378.5s -> 3871.9s (+14.6%)
  4. pr-check-1: 1704.8s -> 1944.8s (+14.1%)
  5. x86_64-gnu-gcc: 3135.0s -> 3539.2s (+12.9%)
  6. dist-x86_64-apple: 7034.7s -> 7918.2s (+12.6%)
  7. test-various: 6532.0s -> 7318.2s (+12.0%)
  8. x86_64-rust-for-linux: 2870.8s -> 3208.8s (+11.8%)
  9. dist-apple-various: 4078.6s -> 3617.3s (-11.3%)
  10. dist-aarch64-llvm-mingw: 6546.5s -> 5988.1s (-8.5%)
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
Copy Markdown
Collaborator

Finished benchmarking commit (dc47a69): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (secondary 0.8%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
0.8%[0.8%, 0.9%]2
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)--0

Cycles

Results (secondary -4.0%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-4.0%[-4.0%, -4.0%]1
All ❌✅ (primary)--0

Binary size

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

Bootstrap: 473.976s -> 475.622s (0.35%)
Artifact size: 389.30 MiB -> 389.31 MiB (0.00%)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Dec 16, 2025
…li-obk
dont create unnecessary `DefId`s under mgca
Fixesrust-lang#149977Fixesrust-lang#148838
Accidentally left this out of rust-lang#149136 even though being able to do this was a large part of the point of the PR :3
First ICE was caused by the fact that we create a defid but never lower the nodeid associated with it to a hirid which later parts of the compiler can't handle.
See test for second ICE
r? oli-obk
rust-timer added a commit that referenced this pull request Dec 17, 2025
Rollup merge of #150025 - BoxyUwU:mgca_no_unused_defids, r=oli-obk
dont create unnecessary `DefId`s under mgca
Fixes#149977Fixes#148838
Accidentally left this out of #149136 even though being able to do this was a large part of the point of the PR :3
First ICE was caused by the fact that we create a defid but never lower the nodeid associated with it to a hirid which later parts of the compiler can't handle.
See test for second ICE
r? oli-obk
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Dec 17, 2025
dont create unnecessary `DefId`s under mgca
Fixesrust-lang/rust#149977Fixesrust-lang/rust#148838
Accidentally left this out of rust-lang/rust#149136 even though being able to do this was a large part of the point of the PR :3
First ICE was caused by the fact that we create a defid but never lower the nodeid associated with it to a hirid which later parts of the compiler can't handle.
See test for second ICE
r? oli-obk
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: generics_of: unexpected node kind ConstArg(ConstArg

6 participants

@BoxyUwU@rustbot@rust-log-analyzer@bors@oli-obk@rust-timer