mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-03 01:25:15 +00:00
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