Files
rust/compiler/rustc_trait_selection
Jacob Pratt aedd26976c Rollup merge of #154853 - lapla-cogito:normlize_projecttion_const, r=BoxyUwU
mgca: Register `ConstArgHasType` when normalizing projection consts

Fixes https://github.com/rust-lang/rust/issues/152962
Fixes rust-lang/rust#154748
Fixes rust-lang/rust#154750

When running CTFE on a MIR body, normalizing a type const within that body can change the type of the resulting value, causing the MIR to become ill-formed. Since no prior error has been reported at that point, MIR validation fires a `span_bug!`. The existing `ConstArgHasType` check in `wfcheck::check_type_const` does catch this at the definition site, but due to query evaluation ordering, the normalization path can reach MIR validation before that check has run.

Fix this by registering a `ConstArgHasType(ct, expected_ty)` obligation/goal when normalizing projection consts (both trait and inherent), in both the old and new trait solvers. This ensures the type mismatch is reported as an error during normalization itself, which taints the MIR before validation runs.

The first commit fixes the original case reported in the issue. The second commit fixes a different ICE pattern reported within the issue (see https://github.com/rust-lang/rust/issues/152962#issuecomment-4148696731).

r? BoxyUwU
2026-06-11 00:33:57 -04:00
..
2026-04-08 21:09:07 +02:00