Skip to content

Commit 480576f

Browse files
committed
A lil more
1 parent 40f0f41 commit 480576f

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -1071,12 +1071,8 @@ pub(crate) struct MatchAutomatonStep<'a, 'c, 'pat, 'tcx> {
10711071
place: PlaceBuilder<'tcx>,
10721072
/// ... depending on the result, branch to one of these candidate lists...
10731073
target_candidates: Vec<Vec<&'a mut Candidate<'pat, 'tcx>>>,
1074-
/// ... if it doesn't match, continue with these...
1074+
/// ... if it doesn't match, continue with these.
10751075
remaining_candidates: &'a mut [&'c mut Candidate<'pat, 'tcx>],
1076-
/// ... and if nothing matches, continue to this block.
1077-
otherwise_block: &'a mut Option<BasicBlock>,
1078-
/// Track places that need fake borrows.
1079-
fake_borrows: &'a mut Option<FxIndexSet<Place<'tcx>>>,
10801076
}
10811077

10821078
impl<'b, 'c, 'pat, 'tcx> std::fmt::Debug for MatchAutomatonStep<'b, 'c, 'pat, 'tcx> {
@@ -1414,8 +1410,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
14141410
match first_candidate.match_pairs[0].pattern.kind {
14151411
PatKind::Or { .. } => (),
14161412
_ => {
1417-
let step = self.build_test_step(candidates, otherwise_block, fake_borrows);
1418-
self.perform_test(span, scrutinee_span, block, step);
1413+
let step = self.build_test_step(candidates, fake_borrows);
1414+
self.perform_test(span, scrutinee_span, block, otherwise_block, fake_borrows, step);
14191415
return;
14201416
}
14211417
}
@@ -1648,8 +1644,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16481644
fn build_test_step<'pat, 'b, 'c>(
16491645
&mut self,
16501646
mut candidates: &'b mut [&'c mut Candidate<'pat, 'tcx>],
1651-
otherwise_block: &'b mut Option<BasicBlock>,
1652-
fake_borrows: &'b mut Option<FxIndexSet<Place<'tcx>>>,
1647+
fake_borrows: &mut Option<FxIndexSet<Place<'tcx>>>,
16531648
) -> MatchAutomatonStep<'b, 'c, 'pat, 'tcx> {
16541649
// extract the match-pair from the highest priority candidate
16551650
let match_pair = &candidates.first().unwrap().match_pairs[0];
@@ -1720,8 +1715,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17201715
place: match_place,
17211716
remaining_candidates: candidates,
17221717
target_candidates,
1723-
otherwise_block,
1724-
fake_borrows,
17251718
}
17261719
}
17271720

compiler/rustc_mir_build/src/build/matches/test.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use crate::build::expr::as_place::PlaceBuilder;
99
use crate::build::matches::{Candidate, MatchPair, Test, TestKind};
1010
use crate::build::Builder;
11-
use rustc_data_structures::fx::FxIndexMap;
11+
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1212
use rustc_hir::{LangItem, RangeEnd};
1313
use rustc_index::bit_set::BitSet;
1414
use rustc_middle::mir::*;
@@ -155,6 +155,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
155155
match_start_span: Span,
156156
scrutinee_span: Span,
157157
block: BasicBlock,
158+
otherwise_block: &mut Option<BasicBlock>,
159+
fake_borrows: &mut Option<FxIndexSet<Place<'tcx>>>,
158160
step: MatchAutomatonStep<'_, '_, '_, 'tcx>,
159161
) {
160162
let test = &step.test;
@@ -170,7 +172,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
170172
// otherwise it's the `otherwise_block`.
171173
let remainder_start = &mut None;
172174
let remainder_start = if step.remaining_candidates.is_empty() {
173-
&mut *step.otherwise_block
175+
&mut *otherwise_block
174176
} else {
175177
remainder_start
176178
};
@@ -191,7 +193,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
191193
candidate_start,
192194
remainder_start,
193195
&mut *candidates,
194-
step.fake_borrows,
196+
fake_borrows,
195197
);
196198
candidate_start
197199
} else {
@@ -206,9 +208,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
206208
match_start_span,
207209
scrutinee_span,
208210
remainder_start,
209-
step.otherwise_block,
211+
otherwise_block,
210212
step.remaining_candidates,
211-
step.fake_borrows,
213+
fake_borrows,
212214
);
213215
};
214216

0 commit comments

Comments
 (0)