1
Fork 0

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>,
) {
let terminator = caller_body[callsite.block].terminator.take().unwrap();
match terminator.kind {
TerminatorKind::Call { args, destination, unwind, .. } => {
let TerminatorKind::Call { args, destination, unwind, .. } = terminator.kind else {
bug!("unexpected terminator kind {:?}", terminator.kind);
};
// If the call is something like `a[*i] = f(i)`, where
// `i : &mut usize`, then just duplicating the `a[*i]`
// 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
// `required_consts`, here we may not only have `ConstKind::Unevaluated`
// because we are calling `instantiate_and_normalize_erasing_regions`.
caller_body.required_consts.extend(
callee_body.required_consts.iter().copied().filter(|&ct| match ct.const_ {
caller_body.required_consts.extend(callee_body.required_consts.iter().copied().filter(
|&ct| match ct.const_ {
Const::Ty(_) => {
bug!("should never encounter ty::UnevaluatedConst in `required_consts`")
}
Const::Val(..) | Const::Unevaluated(..) => true,
}),
);
}
kind => bug!("unexpected terminator kind {:?}", kind),
}
},
));
}
fn make_call_args(