Skip to content

Commit 5f910fa

Browse files
authored
Rollup merge of #58687 - kenta7777:reduce-miri-code-repetition, r=oli-obk
Reduce Miri Code Repetition like `(n << amt) >> amt` This Pull Request fixes a part of [#49937](#49937).
2 parents 554aed6 + 46f1cc6 commit 5f910fa

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)