Skip to content

Commit 5fd47f5

Browse files
committed
Use if let instead of match with one meaningful arm
1 parent a1e8b45 commit 5fd47f5

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -623,33 +623,24 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
623623
// checked by const-qualification, which also
624624
// promotes any complex rvalues to constants.
625625
if i == 2 && intrinsic.unwrap().starts_with("simd_shuffle") {
626-
match arg {
627-
// The shuffle array argument is usually not an explicit constant,
628-
// but specified directly in the code. This means it gets promoted
629-
// and we can then extract the value by evaluating the promoted.
630-
mir::Operand::Copy(_place) | mir::Operand::Move(_place) => {
631-
}
632-
633-
mir::Operand::Constant(constant) => {
634-
let c = self.eval_mir_constant(constant);
635-
let (llval, ty) = self.simd_shuffle_indices(
636-
&bx,
637-
constant.span,
638-
constant.literal.ty,
639-
c,
640-
);
641-
return OperandRef {
642-
val: Immediate(llval),
643-
layout: bx.layout_of(ty)
644-
};
645-
}
626+
if let mir::Operand::Constant(constant) = arg {
627+
let c = self.eval_mir_constant(constant);
628+
let (llval, ty) = self.simd_shuffle_indices(
629+
&bx,
630+
constant.span,
631+
constant.literal.ty,
632+
c,
633+
);
634+
return OperandRef {
635+
val: Immediate(llval),
636+
layout: bx.layout_of(ty)
637+
};
646638
}
647639
}
648640

649641
self.codegen_operand(&mut bx, arg)
650642
}).collect();
651643

652-
653644
bx.codegen_intrinsic_call(*instance.as_ref().unwrap(), &fn_abi, &args, dest,
654645
terminator.source_info.span);
655646

0 commit comments

Comments
 (0)