From 3a83422c136533592618da1ec0a2abee0ef5e5d9 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sun, 12 Jan 2025 14:10:26 +0000 Subject: [PATCH 1/8] Fix ICE-133063 If all subcandidates have never-pattern, the parent candidate should have otherwise_block because some methods expect the candidate has the block. Signed-off-by: Shunpoco --- .../src/builder/matches/mod.rs | 8 ++-- ...ICE-133063-never-arm-no-otherwise-block.rs | 21 +++++++++++ ...133063-never-arm-no-otherwise-block.stderr | 37 +++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index b944d13fb0d24..4b8d33c0dd636 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1958,7 +1958,7 @@ 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; } @@ -2000,8 +2000,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } }); if candidate.subcandidates.is_empty() { - // If `candidate` has become a leaf candidate, ensure it has a `pre_binding_block`. - candidate.pre_binding_block = Some(self.cfg.start_new_block()); + // If `candidate` has become a leaf candidate, ensure it has a `pre_binding_block` and `otherwise_block`. + let next_block = self.cfg.start_new_block(); + candidate.pre_binding_block = Some(next_block); + candidate.otherwise_block = Some(next_block); } } diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs new file mode 100644 index 0000000000000..a9527d7d0c445 --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs @@ -0,0 +1,21 @@ +#![feature(never_patterns)] +#![feature(if_let_guard)] +#![allow(incomplete_features)] + +fn split_last(_: &()) -> Option<(&i32, &i32)> { + None +} + +fn assign_twice() { + loop { + match () { + (!| //~ ERROR: mismatched types + !) if let _ = split_last(&()) => {} //~ ERROR a never pattern is always unreachable + //~^ ERROR: mismatched types + //~^^ WARNING: irrefutable `if let` guard pattern [irrefutable_let_patterns] + _ => {} + } + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr new file mode 100644 index 0000000000000..896c95f1866fe --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr @@ -0,0 +1,37 @@ +error: a never pattern is always unreachable + --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:46 + | +LL | !) if let _ = split_last(&()) => {} + | ^^ + | | + | this will never be executed + | help: remove this expression + +error: mismatched types + --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:12:14 + | +LL | (!| + | ^ a never pattern must be used on an uninhabited type + | + = note: the matched value is of type `()` + +error: mismatched types + --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:13 + | +LL | !) if let _ = split_last(&()) => {} + | ^ a never pattern must be used on an uninhabited type + | + = note: the matched value is of type `()` + +warning: irrefutable `if let` guard pattern + --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:19 + | +LL | !) if let _ = split_last(&()) => {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this pattern will always match, so the guard is useless + = help: consider removing the guard and adding a `let` inside the match arm + = note: `#[warn(irrefutable_let_patterns)]` on by default + +error: aborting due to 3 previous errors; 1 warning emitted + From 8a57fa634c46273dab0a283d2ee151735342c514 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sun, 12 Jan 2025 14:44:36 +0000 Subject: [PATCH 2/8] 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 --- .../src/builder/matches/mod.rs | 8 ++--- .../ICE-133117-duplicate-never-arm.rs | 12 +++++++ .../ICE-133117-duplicate-never-arm.stderr | 36 +++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 4b8d33c0dd636..7e7c5ceee937e 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -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 diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs new file mode 100644 index 0000000000000..884dbacbaa98f --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs @@ -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 + } +} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr new file mode 100644 index 0000000000000..4b8de102a7b55 --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr @@ -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 + From 8c0c149bb007d3a8b8305c7a4ccaf4c30acfc9c2 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sun, 12 Jan 2025 15:16:24 +0000 Subject: [PATCH 3/8] Remove solved crashes Signed-off-by: Shunpoco --- tests/crashes/130779.rs | 11 ----------- tests/crashes/133063.rs | 8 -------- tests/crashes/133117.rs | 8 -------- 3 files changed, 27 deletions(-) delete mode 100644 tests/crashes/130779.rs delete mode 100644 tests/crashes/133063.rs delete mode 100644 tests/crashes/133117.rs diff --git a/tests/crashes/130779.rs b/tests/crashes/130779.rs deleted file mode 100644 index f0fd81fff4449..0000000000000 --- a/tests/crashes/130779.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #130779 -#![feature(never_patterns)] - -enum E { A } - -fn main() { - match E::A { - ! | - if true => {} - } -} diff --git a/tests/crashes/133063.rs b/tests/crashes/133063.rs deleted file mode 100644 index 132b5486170a8..0000000000000 --- a/tests/crashes/133063.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #133063 - -fn foo(x: !) { - match x { - (! | !) if false => {} - _ => {} - } -} diff --git a/tests/crashes/133117.rs b/tests/crashes/133117.rs deleted file mode 100644 index 751c82626d574..0000000000000 --- a/tests/crashes/133117.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #133117 - -fn main() { - match () { - (!|!) if true => {} - (!|!) if true => {} - } -} From 0385dd4719e0ca1ab1a16b6f060bc6a3d1bf2dd9 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Sun, 12 Jan 2025 15:21:24 +0000 Subject: [PATCH 4/8] Fix ICE-130779 Signed-off-by: Shunpoco --- ...CE-130779-never-arm-no-oatherwise-block.rs | 12 +++++++ ...30779-never-arm-no-oatherwise-block.stderr | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.rs create mode 100644 tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.rs new file mode 100644 index 0000000000000..2a7e730af16ba --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.rs @@ -0,0 +1,12 @@ +#![feature(never_patterns)] +#![allow(incomplete_features)] + +enum E { A } + +fn main() { + match E::A { + ! | //~ ERROR: a trailing `|` is not allowed in an or-pattern + //~^ ERROR: mismatched types + if true => {} //~ ERROR: a never pattern is always unreachable + } +} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr new file mode 100644 index 0000000000000..26731e29ffc57 --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-130779-never-arm-no-oatherwise-block.stderr @@ -0,0 +1,33 @@ +error: a trailing `|` is not allowed in an or-pattern + --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:8:11 + | +LL | ! | + | - ^ + | | + | while parsing this or-pattern starting here + | +help: remove the `|` + | +LL - ! | +LL + ! + | + +error: a never pattern is always unreachable + --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:10:20 + | +LL | if true => {} + | ^^ + | | + | this will never be executed + | help: remove this expression + +error: mismatched types + --> $DIR/ICE-130779-never-arm-no-oatherwise-block.rs:8:9 + | +LL | ! | + | ^ a never pattern must be used on an uninhabited type + | + = note: the matched value is of type `E` + +error: aborting due to 3 previous errors + From e7db0925d1441990ceb8236b5d4015f9a2ba333c Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 22 Jan 2025 01:14:43 +0000 Subject: [PATCH 5/8] address review: modify ICE-133117-duplicated-never-arm.rs Use enum Void to avoid mistmatched types error Signed-off-by: Shunpoco --- .../ICE-133117-duplicate-never-arm.rs | 14 +++++---- .../ICE-133117-duplicate-never-arm.stderr | 30 +++++-------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs index 884dbacbaa98f..bca2ab5657021 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.rs @@ -1,12 +1,14 @@ +#![feature(never_type)] #![feature(never_patterns)] #![allow(incomplete_features)] -fn main() { - match () { - (!| - //~^ ERROR: mismatched types - !) if true => {} //~ ERROR a never pattern is always unreachable - //~^ ERROR: mismatched types +enum Void {} + +fn foo(x: Void) { + match x { + (!|!) if true => {} //~ ERROR a never pattern is always unreachable (!|!) if true => {} //~ ERROR a never pattern is always unreachable } } + +fn main() {} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr index 4b8de102a7b55..5da9642dc1998 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133117-duplicate-never-arm.stderr @@ -1,11 +1,11 @@ error: a never pattern is always unreachable - --> $DIR/ICE-133117-duplicate-never-arm.rs:8:23 + --> $DIR/ICE-133117-duplicate-never-arm.rs:9:26 | -LL | !) if true => {} - | ^^ - | | - | this will never be executed - | help: remove this expression +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 @@ -16,21 +16,5 @@ 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 +error: aborting due to 2 previous errors From d8a216b866ff238589005fb1ea4c54644d8d24bf Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 22 Jan 2025 01:27:15 +0000 Subject: [PATCH 6/8] address review: modify ICE-133063-never-arm-no-otherwise-block.rs - Use enum Void to avoid mismatched types error - We don't need to use if let to check the ICE Signed-off-by: Shunpoco --- ...ICE-133063-never-arm-no-otherwise-block.rs | 15 +++---- ...133063-never-arm-no-otherwise-block.stderr | 40 ++++--------------- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs index a9527d7d0c445..4f52f6ee4bd91 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.rs @@ -1,18 +1,13 @@ +#![feature(never_type)] #![feature(never_patterns)] -#![feature(if_let_guard)] #![allow(incomplete_features)] -fn split_last(_: &()) -> Option<(&i32, &i32)> { - None -} +enum Void {} -fn assign_twice() { +fn foo(x: Void) { loop { - match () { - (!| //~ ERROR: mismatched types - !) if let _ = split_last(&()) => {} //~ ERROR a never pattern is always unreachable - //~^ ERROR: mismatched types - //~^^ WARNING: irrefutable `if let` guard pattern [irrefutable_let_patterns] + match x { + (!|!) if false => {} //~ ERROR a never pattern is always unreachable _ => {} } } diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr index 896c95f1866fe..cc451fed31805 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/ICE-133063-never-arm-no-otherwise-block.stderr @@ -1,37 +1,11 @@ error: a never pattern is always unreachable - --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:46 + --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:10:31 | -LL | !) if let _ = split_last(&()) => {} - | ^^ - | | - | this will never be executed - | help: remove this expression +LL | (!|!) if false => {} + | ^^ + | | + | this will never be executed + | help: remove this expression -error: mismatched types - --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:12:14 - | -LL | (!| - | ^ a never pattern must be used on an uninhabited type - | - = note: the matched value is of type `()` - -error: mismatched types - --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:13 - | -LL | !) if let _ = split_last(&()) => {} - | ^ a never pattern must be used on an uninhabited type - | - = note: the matched value is of type `()` - -warning: irrefutable `if let` guard pattern - --> $DIR/ICE-133063-never-arm-no-otherwise-block.rs:13:19 - | -LL | !) if let _ = split_last(&()) => {} - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this pattern will always match, so the guard is useless - = help: consider removing the guard and adding a `let` inside the match arm - = note: `#[warn(irrefutable_let_patterns)]` on by default - -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 1 previous error From 481ed2d9319a28b770da60f4567e55f5cc053835 Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 22 Jan 2025 01:51:11 +0000 Subject: [PATCH 7/8] address review: modify matches/mod.rs The candidate shouldn't have false_edge_start_block if it has sub candidates. In remove_never_subcandidates(), the false_edge_start_block from the first sub candidte is assigned to a value and the value is later used if all sub candidates are removed and candidate doesn't have false_edge_start_block. In merge_trivial_subcandidates, I leave the if block which assign a false_edge_start_block into the candidate as before I put this commit since compile panics. Signed-off-by: Shunpoco --- compiler/rustc_mir_build/src/builder/matches/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 7e7c5ceee937e..430854974b38e 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1940,10 +1940,6 @@ 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; @@ -1963,6 +1959,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { 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 // all to join up at a single shared pre-binding block. @@ -1986,6 +1986,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { return; } + let false_edge_start_block = candidate.subcandidates[0].false_edge_start_block; candidate.subcandidates.retain_mut(|candidate| { if candidate.extra_data.is_never { candidate.visit_leaves(|subcandidate| { @@ -2004,6 +2005,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let next_block = self.cfg.start_new_block(); candidate.pre_binding_block = Some(next_block); candidate.otherwise_block = Some(next_block); + // In addition, if `candidate` should have `false_edge_start_block`. + if candidate.false_edge_start_block.is_none() { + candidate.false_edge_start_block = false_edge_start_block; + } } } From 7275bdf6ec396d052b6dae8af8597b5eebf1f66f Mon Sep 17 00:00:00 2001 From: Shunpoco Date: Wed, 22 Jan 2025 02:42:11 +0000 Subject: [PATCH 8/8] modify comment Signed-off-by: Shunpoco --- compiler/rustc_mir_build/src/builder/matches/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 430854974b38e..b21ec8f3083b3 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -2005,7 +2005,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let next_block = self.cfg.start_new_block(); candidate.pre_binding_block = Some(next_block); candidate.otherwise_block = Some(next_block); - // In addition, if `candidate` should have `false_edge_start_block`. + // In addition, if `candidate` doesn't have `false_edge_start_block`, it should be assigned here. if candidate.false_edge_start_block.is_none() { candidate.false_edge_start_block = false_edge_start_block; }