Skip to content

Fix ICE-133117: multiple never-pattern arm doesn't have false_edge_start_block #135409

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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/builder/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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