diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-22 20:37:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-22 20:37:24 +0100 |
| commit | f8759830353d9d0391712552f7359489cac97f73 (patch) | |
| tree | 9f3220801e6d2d0706236e1522e5e6d4a5e62e56 /compiler/rustc_interface/src/interface.rs | |
| parent | 9206ba535c28d13ae00a78dc2a425fe7c75bc0ec (diff) | |
| parent | 7275bdf6ec396d052b6dae8af8597b5eebf1f66f (diff) | |
| download | rust-f8759830353d9d0391712552f7359489cac97f73.tar.gz rust-f8759830353d9d0391712552f7359489cac97f73.zip | |
Rollup merge of #135409 - Shunpoco:issue-133117-ICE-never-false-edge-start-block, r=Nadrieril
Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block Fixes #133117 , and close fixes #133063 , fixes #130779 In order to fix ICE-133117, at first I needed to tackle to ICE-133063 (this fixed 130779 as well). ### ICE-133063 and ICE-130779 This ICE is caused by those steps: 1. An arm has or-pattern, and all of the sub-candidates are never-pattern 2. In that case, all sub-candidates are removed in remove_never_subcandidates(). So the arm (candidate) has no sub-candidate. 3. In the current implementation, if there is no sub-candidate, the function assigns `pre_binding_block` into the candidate ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L2002-L2004)). However, otherwise_block should be assigned to the candidate as well, because the otherwise_block is unwrapped in multiple place (like in lower_match_tree()). As a result, it causes the panic. I simply added the same block as pre_binding_block into otherwise_block, but I'm wondering if there is a better block to assign to otherwise_block (is it ok to assign the same block into pre_binding and otherwise?) ### ICE-133117 This is caused by those steps: 1. There are two arms, both are or-pattern and each has one match-pair (in the test code, both are `(!|!)`), and the second arm has a guard. 2. In match_candidate() for the first arm, it expands the second arm’s sub-candidates as well ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1800-L1805)). As a result, the root candidate of the second arm is not evaluated/modified in match_candidate(). So a false_edge_start_block is not assigned to the candidate. 3. merge_trivial_subcandidates() is called against the candidate for the second arm. It just returns immediately because the candidate has a guard. So a flase_edge_start_block is not assigned to the candidate also in this function. 4. remove_never_subcandidates() is called against the candidate. Since all sub-candidates are never-pattern. they are removed. 5. In lower_match_tree(), since there is no sub-candidate for the candidate, the candidate itself is evaluated in visit_leave_rev ([here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/builder/matches/mod.rs#L1532)). Because the candidate has no false_edge_start_block, it causes the panic. So I modified the order of if blocks in merge_trivial_subcandidates() to assign a false_edge_start_block if the candidate doesn't have.
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
0 files changed, 0 insertions, 0 deletions
