Adopt let else in more places

This commit is contained in:
est31
2022-02-19 00:48:49 +01:00
parent b8c56fa8c3
commit 2ef8af6619
132 changed files with 539 additions and 881 deletions

View File

@@ -126,11 +126,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
candidate: &Candidate<'pat, 'tcx>,
variants: &mut BitSet<VariantIdx>,
) -> 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 {
@@ -421,9 +418,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}
let deref_ty = match *ty.kind() {
ty::Ref(_, deref_ty, _) => deref_ty,
_ => bug!("non_scalar_compare called on non-reference type: {}", ty),
let ty::Ref(_, deref_ty, _) = *ty.kind() else {
bug!("non_scalar_compare called on non-reference type: {}", ty);
};
let eq_def_id = self.tcx.require_lang_item(LangItem::PartialEq, None);

View File

@@ -266,9 +266,8 @@ fn liberated_closure_env_ty(
) -> Ty<'_> {
let closure_ty = tcx.typeck_body(body_id).node_type(closure_expr_id);
let (closure_def_id, closure_substs) = match *closure_ty.kind() {
ty::Closure(closure_def_id, closure_substs) => (closure_def_id, closure_substs),
_ => bug!("closure expr does not have closure type: {:?}", closure_ty),
let ty::Closure(closure_def_id, closure_substs) = *closure_ty.kind() else {
bug!("closure expr does not have closure type: {:?}", closure_ty);
};
let bound_vars =