Skip to content

Commit

Permalink
Rollup merge of rust-lang#124064 - Zalathar:otherwise-block, r=Nadrieril
Browse files Browse the repository at this point in the history
Move confusing comment about otherwise blocks in `lower_match_tree`

This comment was historically inside a block guarded by `if let Some(otherwise_block) = otherwise`.

When rust-lang#120978 made the “otherwise block” non-optional, it also flattened that region of code. Doing so left this comment awkwardly stranded above an unrelated line of code, without its original context.

We can restore that context by moving it above the declaration of `otherwise`.

r? `@Nadrieril`
  • Loading branch information
matthiaskrgr authored Apr 18, 2024
2 parents 3489064 + d3c3051 commit da901d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let fake_borrows = match_has_guard
.then(|| util::FakeBorrowCollector::collect_fake_borrows(self, candidates));

// See the doc comment on `match_candidates` for why we have an
// otherwise block. Match checking will ensure this is actually
// unreachable.
let otherwise_block = self.cfg.start_new_block();

// This will generate code to test scrutinee_place and
// branch to the appropriate arm block
self.match_candidates(match_start_span, scrutinee_span, block, otherwise_block, candidates);

// See the doc comment on `match_candidates` for why we may have an
// otherwise block. Match checking will ensure this is actually
// unreachable.
let source_info = self.source_info(scrutinee_span);

// Matching on a `scrutinee_place` with an uninhabited type doesn't
Expand Down

0 comments on commit da901d3

Please sign in to comment.