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 check in eval_in_interpreter() to return a ErrorHandled::TooGeneric, for any other logic similar to what I observed in reachable.rs or at least allow that logic report some kinda of error.

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

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.
@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
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)]` 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: can't type-check body of DefId

3 participants