Skip to content

Conversation

@camelid
Copy link
Member

@camelid camelid commented Dec 30, 2025

Fixes #144547.
Fixes #140891.

In the future, we likely want to make the check less likely to be missed by reducing the number of external entry points to HIR type lowering.

Note: If this causes pass->error regressions (not truly regressions because those cases were mistakenly accepted), they can easily be avoided for the time being by only running the check if is_self_alias is true or mgca is enabled.

  • Fix parsing of mgca const blocks in array repeat exprs
  • Use more principled check for generics in const ops

@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2025

HIR ty lowering was modified

cc @fmease

@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. labels Dec 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 30, 2025

r? @mati865

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

@camelid camelid assigned BoxyUwU and unassigned mati865 Dec 30, 2025
@camelid camelid added the A-const-generics Area: const generics (parameters and arguments) label Dec 30, 2025
@camelid camelid force-pushed the mgca-forbid-params-properly branch from 467a547 to bb5a2ad Compare December 30, 2025 19:06
@rust-log-analyzer

This comment has been minimized.

There was an inconsistency where in the case of array repeat
expressions, we forgot to eat the `const` keyword of mgca const blocks.
Thus, we ended up parsing them as an anon const containing an inline
const, instead of simply an anon const as they should be.

This commit fixes that issue and also makes the parsing for mgca const
blocks more consistent and simpler in general. For example, we avoid
doing a lookahead check to ensure there's a curly brace coming. There
should always be one after a `const` keyword in an expression context,
and that's handled by the mgca const block parsing function.
@camelid camelid force-pushed the mgca-forbid-params-properly branch 2 times, most recently from a43382b to fd9687d Compare December 30, 2025 19:34
@rust-log-analyzer

This comment has been minimized.

@camelid camelid force-pushed the mgca-forbid-params-properly branch 2 times, most recently from a9260e0 to f8ae75a Compare December 31, 2025 02:15
@rust-log-analyzer

This comment has been minimized.

@BoxyUwU BoxyUwU 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 Jan 1, 2026
@camelid camelid force-pushed the mgca-forbid-params-properly branch from f8ae75a to 65bba87 Compare January 1, 2026 22:37
@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2026

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@camelid camelid 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 Jan 1, 2026
@rust-log-analyzer

This comment has been minimized.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 2, 2026
@rust-log-analyzer

This comment has been minimized.

Instead of using a visitor in typeck, we just check, whenever lowering a
use of a param, whether the parent item is an MCG anon const during hir
ty lowering (and instantiate_value_path). If so, we report an error
since MCG anon consts should never be able to use generics. All other
kinds of anon consts are at least syntactically allowed to use generic
params.

We use a `TypeFolder` to accomplish this; this way, we look at the
fully explicit semantic representation of the type/const/whatever and
don't miss subtle cases like `Self` type aliases.
Now that we avoid a fatal error, they can all be one test.
@camelid camelid force-pushed the mgca-forbid-params-properly branch from 94e79a8 to f71e938 Compare January 2, 2026 02:12
@camelid
Copy link
Member Author

camelid commented Jan 2, 2026

@bors r=BoxyUwU

fixed broken doc link (cc #133661)

@bors
Copy link
Collaborator

bors commented Jan 2, 2026

📌 Commit f71e938 has been approved by BoxyUwU

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 2, 2026

⌛ Testing commit f71e938 with merge a47f4df...

@bors
Copy link
Collaborator

bors commented Jan 2, 2026

☀️ Test successful - checks-actions
Approved by: BoxyUwU
Pushing a47f4df to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 2, 2026
@bors bors merged commit a47f4df into rust-lang:main Jan 2, 2026
12 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

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 056908d (parent) -> a47f4df (this PR)

Test differences

Show 59 test diffs

Stage 1

  • [crashes] tests/crashes/140891.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/early-bound-param-lt-bad.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-2.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-3.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-4.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-5.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-6.rs: pass -> [missing] (J0)
  • [ui] tests/ui/const-generics/mgca/higher-ranked-lts-bad.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/higher-ranked-lts-good.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/late-bound-param-lt-bad.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/selftyalias-containing-param.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/mgca/selftyparam.rs: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/type-relative-path-144547.rs#mgca: [missing] -> pass (J0)
  • [ui] tests/ui/const-generics/type-relative-path-144547.rs#min: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/const-generics/mgca/early-bound-param-lt-bad.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-2.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-3.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-4.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-5.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/explicit_anon_consts-6.rs: pass -> [missing] (J1)
  • [ui] tests/ui/const-generics/mgca/higher-ranked-lts-bad.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/higher-ranked-lts-good.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/late-bound-param-lt-bad.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/selftyalias-containing-param.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/mgca/selftyparam.rs: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/type-relative-path-144547.rs#mgca: [missing] -> pass (J1)
  • [ui] tests/ui/const-generics/type-relative-path-144547.rs#min: [missing] -> pass (J1)
  • [crashes] tests/crashes/140891.rs: pass -> [missing] (J2)

Additionally, 31 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 a47f4dfd7f496ed51a383c540497899f9e3f91b4 --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-aux: 6993.1s -> 7880.1s (+12.7%)
  2. i686-gnu-1: 7253.7s -> 8162.1s (+12.5%)
  3. x86_64-gnu-gcc: 3039.0s -> 3416.3s (+12.4%)
  4. dist-aarch64-msvc: 5650.7s -> 6290.9s (+11.3%)
  5. aarch64-apple: 9042.1s -> 10044.3s (+11.1%)
  6. x86_64-gnu-llvm-20: 4159.7s -> 4574.0s (+10.0%)
  7. x86_64-gnu-debug: 6605.1s -> 7215.8s (+9.2%)
  8. x86_64-gnu-llvm-21-1: 4200.9s -> 4562.4s (+8.6%)
  9. pr-check-1: 1781.7s -> 1934.7s (+8.6%)
  10. aarch64-msvc-2: 6123.8s -> 6602.7s (+7.8%)
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 (a47f4df): 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.3%] 6
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.3%] 6

Max RSS (memory usage)

Results (primary -1.9%, 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)
- - 0
Improvements ✅
(primary)
-1.9% [-1.9%, -1.9%] 1
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.1%] 1
All ❌✅ (primary) -1.9% [-1.9%, -1.9%] 1

Cycles

Results (secondary 7.3%)

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

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

Bootstrap: 474.6s -> 473.624s (-0.21%)
Artifact size: 390.83 MiB -> 390.78 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Jan 2, 2026
@camelid camelid deleted the mgca-forbid-params-properly branch January 2, 2026 07:27
@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 2, 2026

Perf regression is unfortunate. I'm not sure what we can do about it 🤔 Doing more work here feels somewhat unavoidable and also necessary to fix the ICEs and generally correctly handle forbidding uses of generic parameters introduced after name resolution ☹️

AprilNEA added a commit to AprilNEA/rust that referenced this pull request Jan 2, 2026
Following rust-lang#150519, the `forbid_generic` field in `Res::SelfTyAlias` is
no longer needed. The check for generic `Self` types in anonymous
constants is now handled by `check_param_uses_if_mcg` in HIR type
lowering, making this field redundant.

This removes:
- The `forbid_generic` field from `Res::SelfTyAlias`
- The hack in `rustc_resolve` that set `forbid_generic: true` when
encountering `Self` in constant items
- Related pattern matching and field propagation code
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 3, 2026
…neric-field, r=camelid,BoxyUwU

Remove unneeded `forbid_generic` field from `Res::SelfTyAlias`

Following rust-lang#150519, the `forbid_generic` field in `Res::SelfTyAlias` is no longer needed and can be removed.

- Remove the `forbid_generic: bool` field from `Res::SelfTyAlias`
- Simplify the ConstantItem rib handling in `rustc_resolve` - no longer need to mutate res to set `forbid_generic: true`
- Update all pattern matches and constructors of `SelfTyAlias`

Closes rust-lang#150579

r? `@camelid`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 3, 2026
…neric-field, r=camelid,BoxyUwU

Remove unneeded `forbid_generic` field from `Res::SelfTyAlias`

Following rust-lang#150519, the `forbid_generic` field in `Res::SelfTyAlias` is no longer needed and can be removed.

- Remove the `forbid_generic: bool` field from `Res::SelfTyAlias`
- Simplify the ConstantItem rib handling in `rustc_resolve` - no longer need to mutate res to set `forbid_generic: true`
- Update all pattern matches and constructors of `SelfTyAlias`

Closes rust-lang#150579

r? ``@camelid``
rust-timer added a commit that referenced this pull request Jan 3, 2026
Rollup merge of #150589 - AprilNEA:remove-unneeded-forbid-generic-field, r=camelid,BoxyUwU

Remove unneeded `forbid_generic` field from `Res::SelfTyAlias`

Following #150519, the `forbid_generic` field in `Res::SelfTyAlias` is no longer needed and can be removed.

- Remove the `forbid_generic: bool` field from `Res::SelfTyAlias`
- Simplify the ConstantItem rib handling in `rustc_resolve` - no longer need to mutate res to set `forbid_generic: true`
- Update all pattern matches and constructors of `SelfTyAlias`

Closes #150579

r? ``@camelid``
@Kobzol
Copy link
Member

Kobzol commented Jan 6, 2026

It's a tiny regression on diesel, I think that we can eat this one.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-const-generics Area: const generics (parameters and arguments) 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: Panic when using constant from associated type trait impl ICE:called Option::unwrap() on a None value

8 participants