Skip to content

Commit 46f1cc6

Browse files
committed
reduce miri code repetition like (n << amt) >> amt
1 parent aadbc45 commit 46f1cc6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/librustc_mir/hair/constant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>(
2121
let param_ty = ParamEnv::reveal_all().and(tcx.lift_to_global(&ty).unwrap());
2222
let width = tcx.layout_of(param_ty).map_err(|_| LitToConstError::Reported)?.size;
2323
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
24-
let shift = 128 - width.bits();
25-
let result = (n << shift) >> shift;
24+
let result = truncate(n, width);
2625
trace!("trunc result: {}", result);
2726
Ok(ConstValue::Scalar(Scalar::Bits {
2827
bits: result,

0 commit comments

Comments
 (0)