Use let else to reduce indentation

This commit is contained in:
Tomasz Miąsko 2023-11-09 00:00:00 +00:00
parent d19980e1ce
commit 525a64fa81

View file

@ -541,8 +541,10 @@ impl<'tcx> Inliner<'tcx> {
mut callee_body: Body<'tcx>, mut callee_body: Body<'tcx>,
) { ) {
let terminator = caller_body[callsite.block].terminator.take().unwrap(); let terminator = caller_body[callsite.block].terminator.take().unwrap();
match terminator.kind { let TerminatorKind::Call { args, destination, unwind, .. } = terminator.kind else {
TerminatorKind::Call { args, destination, unwind, .. } => { bug!("unexpected terminator kind {:?}", terminator.kind);
};
// If the call is something like `a[*i] = f(i)`, where // If the call is something like `a[*i] = f(i)`, where
// `i : &mut usize`, then just duplicating the `a[*i]` // `i : &mut usize`, then just duplicating the `a[*i]`
// Place could result in two different locations if `f` // Place could result in two different locations if `f`
@ -666,17 +668,14 @@ impl<'tcx> Inliner<'tcx> {
// Although we are only pushing `ConstKind::Unevaluated` consts to // Although we are only pushing `ConstKind::Unevaluated` consts to
// `required_consts`, here we may not only have `ConstKind::Unevaluated` // `required_consts`, here we may not only have `ConstKind::Unevaluated`
// because we are calling `instantiate_and_normalize_erasing_regions`. // because we are calling `instantiate_and_normalize_erasing_regions`.
caller_body.required_consts.extend( caller_body.required_consts.extend(callee_body.required_consts.iter().copied().filter(
callee_body.required_consts.iter().copied().filter(|&ct| match ct.const_ { |&ct| match ct.const_ {
Const::Ty(_) => { Const::Ty(_) => {
bug!("should never encounter ty::UnevaluatedConst in `required_consts`") bug!("should never encounter ty::UnevaluatedConst in `required_consts`")
} }
Const::Val(..) | Const::Unevaluated(..) => true, Const::Val(..) | Const::Unevaluated(..) => true,
}), },
); ));
}
kind => bug!("unexpected terminator kind {:?}", kind),
}
} }
fn make_call_args( fn make_call_args(