-
Notifications
You must be signed in to change notification settings - Fork 14k
fix: Do not ICE when missing match arm with ill-formed subty is met #148872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+69
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collaborator
|
Some changes occurred in exhaustiveness checking cc @Nadrieril |
Collaborator
|
r? @chenyukang rustbot has assigned @chenyukang. Use |
Member
|
Thanks! |
Collaborator
chenyukang
reviewed
Nov 13, 2025
bors
added a commit
that referenced
this pull request
Nov 13, 2025
Rollup of 7 pull requests Successful merges: - #147701 (rustdoc: don't ignore path distance for doc aliases) - #148735 (Fix ICE caused by invalid spans for shrink_file) - #148839 (fix rtsan_nonblocking_async lint closure ICE) - #148846 (add a test for combining RPIT with explicit tail calls) - #148872 (fix: Do not ICE when missing match arm with ill-formed subty is met) - #148880 (Remove explicit install of `eslint` inside of `tidy`'s Dockerfile) - #148883 (bootstrap: dont require cmake if local-rebuild is enabled) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Nov 13, 2025
Rollup merge of #148872 - ShoyuVanilla:issue-148192, r=chenyukang fix: Do not ICE when missing match arm with ill-formed subty is met Fixes #148192 The ICE comes from the following line, calling `normalize_erasing_regions` to a projection type whose trait bound is not met: https://github.com/rust-lang/rust/blob/2fcbda6c1a70606bdb09857e01d01fc6229da712/compiler/rustc_pattern_analysis/src/rustc.rs#L185-L194 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. ```rust trait WhereTrait { type Type; } fn foo(e: Enum) { match e { Enum::Map(_) => (), // ICE, while trying to lint missing arms } if let Enum::Map(_) = e {} // ICE, while trying to scrutinize missing ctors (even worse) } enum Enum { Map(()), Map2(<() as WhereTrait>::Type), } ``` This ICE won't be triggered with the following code, as this is filtered out before `check_match` as the existence of ill-formed type inside the variant marks the body as tainted by error in `hir_typeck`, but for the above code, the `hir_typeck` complains nothing because everything it sees is locally correct. ```rust fn foo(e: Enum) { match e { Enum::Map2(_) => (), // No ICE } } ``` 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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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.