Skip to content

Commit b3731ee

Browse files
committed
Fold an if on a match returning a bool directly into the match
1 parent 1b93eda commit b3731ee

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/librustc_mir/const_eval.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,13 @@ fn op_to_const<'tcx>(
6868
op: OpTy<'tcx>,
6969
) -> EvalResult<'tcx, ty::Const<'tcx>> {
7070
// We do not normalize just any data. Only scalar layout and slices.
71-
let normalize = match op.layout.abi {
72-
layout::Abi::Scalar(..) => true,
73-
layout::Abi::ScalarPair(..) => op.layout.ty.is_slice(),
74-
_ => false,
75-
};
76-
let normalized_op = if normalize {
77-
ecx.try_read_immediate(op)?
78-
} else {
79-
match *op {
71+
let normalized_op = match op.layout.abi {
72+
layout::Abi::Scalar(..) => ecx.try_read_immediate(op)?,
73+
layout::Abi::ScalarPair(..) if op.layout.ty.is_slice() => ecx.try_read_immediate(op)?,
74+
_ => match *op {
8075
Operand::Indirect(mplace) => Err(mplace),
8176
Operand::Immediate(val) => Ok(val)
82-
}
77+
},
8378
};
8479
let (val, alloc) = match normalized_op {
8580
Err(MemPlace { ptr, align, meta }) => {

0 commit comments

Comments
 (0)