Rollup merge of #93046 - est31:let_else, r=davidtwco
Use let_else in even more places Followup of #89933, #91018, #91481.
This commit is contained in:
commit
ab19d4a515
9 changed files with 134 additions and 140 deletions
|
@ -1347,23 +1347,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());
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue