Skip to content

Conversation

@Keith-Cancel
Copy link
Contributor

@Keith-Cancel Keith-Cancel commented Jan 13, 2026

This PR fixes #150956 for min_const_generic_args #132980.

The first part of this PR checks in reachable.rs if we have a type const use visit_const_item_rhs(init); instead of calling const_eval_poly_to_alloc()

The second part is I noticed that if const_eval_poly_to_alloc() returns a ErrorHandled::TooGeneric then switches to visit_const_item_rhs(). So further up const_eval_poly_to_alloc() call order it eventual gets to eval_in_interpreter(). So I added a debug_assert in eval_in_interpreter() if we happen to try and run CTFE on a type_const.

The other bit is just a test case, and some duplicated code I noticed.

While the PR does get rid of the ICE for a type_const with pub visibility. If I try using the const though it will ICE with the following:

error: internal compiler error: /home/keith/GitHub/rust_kc/compiler/rustc_const_eval/src/check_consts/qualifs.rs:355:13: expected ConstKind::Param or ConstKind::Value here, found UnevaluatedConst { def: DefId(20:4 ~ colorkit[c783]::TYPE_CONST), args: [] }


thread 'rustc' (819687) panicked at /home/keith/GitHub/rust_kc/compiler/rustc_const_eval/src/check_consts/qualifs.rs:355:13:

I suspect it is a similar issue to inherent associated consts. Since if I apply the same fix I had here:
#150799 (comment)

I then can use the const internally and in external crates without any issues.
Although, did not include that fix since if it is a similar issue it would need to be addressed elsewhere.

r? @BoxyUwU
@rustbot label +F-associated_const_equality +F-min_generic_const_args

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@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 Jan 13, 2026
@rustbot rustbot added F-associated_const_equality `#![feature(associated_const_equality)]` F-min_generic_const_args `#![feature(min_generic_const_args)]` labels Jan 13, 2026
@Keith-Cancel
Copy link
Contributor Author

@BoxyUwU Any changes I need to make?

@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 16, 2026

@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 Jan 16, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2026

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

@Keith-Cancel
Copy link
Contributor Author

Keith-Cancel commented Jan 16, 2026

@rustbot ready, if it looks all good. I can then flatten and rebase it with main.

@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 Jan 16, 2026
@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 16, 2026

You'll need to update your PR description too as the TooGeneric change is no longer present. Can you change the title to something a bit more informative (similar to the comment in the test). There's also no need to link the fixed issue in the title as it's part of the PR description

@Keith-Cancel Keith-Cancel changed the title Fix ICE: can't type-check body of DefId for issue #150956 Fix ICE: When Trying to check visibility of a #[type_const], check RHS instead. Jan 16, 2026
@Keith-Cancel
Copy link
Contributor Author

Keith-Cancel commented Jan 16, 2026

You'll need to update your PR description too as the TooGeneric change is no longer present. Can you change the title to something a bit more informative (similar to the comment in the test). There's also no need to link the fixed issue in the title as it's part of the PR description

@BoxyUwU Fair enough I have updated the description, and title. =)

Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

lgtm! r=me once all the commits have been squashed

View changes since this review

…S instead.

We want to evaluate the rhs of a type_const.

Also added an early return/guard in eval_in_interpreter which is used in functions like `eval_to_allocation_raw_provider`

Lastly add a debug assert to `thir_body()` if we have gotten there with a type_const something as gone wrong.

Get rid of a call to is_type_const() and instead use a match arm.

Change this is_type_const() check to a debug_assert!()

Change to use an if else statment instead.

Update type_const-pub.rs

Fix formatting.

Noticed that this is the same check as is_type_const() centralize it.

Add test case for pub type_const.
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

This PR was rebased onto a different main 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.

@Keith-Cancel
Copy link
Contributor Author

@BoxyUwU Squashed and rebased onto main.

@Keith-Cancel Keith-Cancel requested a review from BoxyUwU January 17, 2026 04:36
@BoxyUwU
Copy link
Member

BoxyUwU commented Jan 17, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 17, 2026

📌 Commit 4c93efa has been approved by BoxyUwU

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Jan 17, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 17, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 17, 2026

☀️ Test successful - CI
Approved by: BoxyUwU
Pushing 9f6cd6d to main...

@rust-bors rust-bors bot merged commit 9f6cd6d into rust-lang:main Jan 17, 2026
12 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 17, 2026
@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 844f131 (parent) -> 9f6cd6d (this PR)

Test differences

Show 4 test diffs

Stage 1

  • [ui] tests/ui/const-generics/mgca/type_const-pub.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/const-generics/mgca/type_const-pub.rs: [missing] -> pass (J1)

Additionally, 2 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 9f6cd6defbd7ef13f6777aa8e43b14d69f0a830a --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-aarch64-llvm-mingw: 5723.2s -> 6698.0s (+17.0%)
  2. x86_64-gnu-llvm-20-2: 4954.6s -> 5630.0s (+13.6%)
  3. x86_64-rust-for-linux: 2506.3s -> 2843.9s (+13.5%)
  4. x86_64-msvc-ext3: 6627.4s -> 5833.3s (-12.0%)
  5. aarch64-msvc-2: 6691.4s -> 6050.7s (-9.6%)
  6. armhf-gnu: 4626.4s -> 5055.7s (+9.3%)
  7. dist-x86_64-apple: 7377.4s -> 6734.9s (-8.7%)
  8. x86_64-gnu-llvm-21-3: 6661.6s -> 6120.9s (-8.1%)
  9. x86_64-gnu-tools: 3159.9s -> 3415.5s (+8.1%)
  10. aarch64-gnu: 7072.6s -> 7635.5s (+8.0%)
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 (9f6cd6d): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -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.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

Results (primary 2.1%)

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

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

Binary size

Results (primary -0.1%, 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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 54
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 24
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 54

Bootstrap: 472.032s -> 472.543s (0.11%)
Artifact size: 383.50 MiB -> 383.42 MiB (-0.02%)

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

Labels

F-associated_const_equality `#![feature(associated_const_equality)]` F-min_generic_const_args `#![feature(min_generic_const_args)]` merged-by-bors This PR was explicitly merged by bors. 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: can't type-check body of DefId

4 participants