Fix ICE-133117
If all subcandidates have never-pattern, we should assign false_edge_start_block to the parent candidate if it doesn't have. merge_trivial_subcandidates does so, but if the candidate has guard it returns before the assignment. Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
This commit is contained in:
parent
3a83422c13
commit
8a57fa634c
3 changed files with 52 additions and 4 deletions
|
|
@ -1940,6 +1940,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
/// in match tree lowering.
|
||||
fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
|
||||
assert!(!candidate.subcandidates.is_empty());
|
||||
if candidate.false_edge_start_block.is_none() {
|
||||
candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
|
||||
}
|
||||
|
||||
if candidate.has_guard {
|
||||
// FIXME(or_patterns; matthewjasper) Don't give up if we have a guard.
|
||||
return;
|
||||
|
|
@ -1958,10 +1962,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// This candidate is about to become a leaf, so unset `or_span`.
|
||||
let or_span = candidate.or_span.take().unwrap();
|
||||
let source_info = self.source_info(or_span);
|
||||
|
||||
if candidate.false_edge_start_block.is_none() {
|
||||
candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
|
||||
}
|
||||
|
||||
// Remove the (known-trivial) subcandidates from the candidate tree,
|
||||
// so that they aren't visible after match tree lowering, and wire them
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
#![feature(never_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
fn main() {
|
||||
match () {
|
||||
(!|
|
||||
//~^ ERROR: mismatched types
|
||||
!) if true => {} //~ ERROR a never pattern is always unreachable
|
||||
//~^ ERROR: mismatched types
|
||||
(!|!) if true => {} //~ ERROR a never pattern is always unreachable
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
error: a never pattern is always unreachable
|
||||
--> $DIR/ICE-133117-duplicate-never-arm.rs:8:23
|
||||
|
|
||||
LL | !) if true => {}
|
||||
| ^^
|
||||
| |
|
||||
| this will never be executed
|
||||
| help: remove this expression
|
||||
|
||||
error: a never pattern is always unreachable
|
||||
--> $DIR/ICE-133117-duplicate-never-arm.rs:10:26
|
||||
|
|
||||
LL | (!|!) if true => {}
|
||||
| ^^
|
||||
| |
|
||||
| this will never be executed
|
||||
| help: remove this expression
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/ICE-133117-duplicate-never-arm.rs:6:10
|
||||
|
|
||||
LL | (!|
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
|
|
||||
= note: the matched value is of type `()`
|
||||
|
||||
error: mismatched types
|
||||
--> $DIR/ICE-133117-duplicate-never-arm.rs:8:9
|
||||
|
|
||||
LL | !) if true => {}
|
||||
| ^ a never pattern must be used on an uninhabited type
|
||||
|
|
||||
= note: the matched value is of type `()`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue