1
Fork 0

Use let_else in even more places

This commit is contained in:
est31 2022-01-18 20:26:13 +01:00
parent 9ad5d82f82
commit b2dd1377c7
9 changed files with 134 additions and 140 deletions

View file

@ -1328,23 +1328,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let mut otherwise = None;
for match_pair in match_pairs {
if let PatKind::Or { ref pats } = *match_pair.pattern.kind {
let or_span = match_pair.pattern.span;
let place = match_pair.place;
first_candidate.visit_leaves(|leaf_candidate| {
self.test_or_pattern(
leaf_candidate,
&mut otherwise,
pats,
or_span,
place.clone(),
fake_borrows,
);
});
} else {
let PatKind::Or { ref pats } = &*match_pair.pattern.kind else {
bug!("Or-patterns should have been sorted to the end");
}
};
let or_span = match_pair.pattern.span;
let place = match_pair.place;
first_candidate.visit_leaves(|leaf_candidate| {
self.test_or_pattern(
leaf_candidate,
&mut otherwise,
pats,
or_span,
place.clone(),
fake_borrows,
);
});
}
let remainder_start = otherwise.unwrap_or_else(|| self.cfg.start_new_block());

View file

@ -88,11 +88,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
switch_ty: Ty<'tcx>,
options: &mut FxIndexMap<&'tcx ty::Const<'tcx>, u128>,
) -> bool {
let match_pair = match candidate.match_pairs.iter().find(|mp| mp.place == *test_place) {
Some(match_pair) => match_pair,
_ => {
return false;
}
let Some(match_pair) = candidate.match_pairs.iter().find(|mp| mp.place == *test_place) else {
return false;
};
match *match_pair.pattern.kind {