fix: Do not ICE when missing match arm with ill-formed subty is met #148872
+69
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #148192
The ICE comes from the following line, calling
normalize_erasing_regionsto a projection type whose trait bound is not met:rust/compiler/rustc_pattern_analysis/src/rustc.rs
Lines 185 to 194 in 2fcbda6
The above function is called while trying to lint missing match arms, or scrutinize ctors of missing(not necessary error) match arms.
So, the following code can trigger ICEs.
This ICE won't be triggered with the following code, as this is filtered out before
check_matchas the existence of ill-formed type inside the variant marks the body as tainted by error inhir_typeck, but for the above code, thehir_typeckcomplains nothing because everything it sees is locally correct.I've considered visiting and wf checking for the match scrutinee before entering
check_match, but that might regress the perf and I think just emitting delayed bug would enough as the normalization failure would be originated by other errors like ill-formdness.