Sync from rust b3ddfeb5a88352aa6d157f722976937da7b97307

This commit is contained in:
bjorn3 2022-12-11 11:05:00 +01:00
commit 8f9a048138

View File

@ -372,8 +372,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
}
}
TerminatorKind::SwitchInt { discr, switch_ty, targets } => {
let discr = codegen_operand(fx, discr).load_scalar(fx);
TerminatorKind::SwitchInt { discr, targets } => {
let discr = codegen_operand(fx, discr);
let switch_ty = discr.layout().ty;
let discr = discr.load_scalar(fx);
let use_bool_opt = switch_ty.kind() == fx.tcx.types.bool.kind()
|| (targets.iter().count() == 1 && targets.iter().next().unwrap().0 == 0);