Skip to content

Commit

Permalink
reduce miri code repetition like (n << amt) >> amt
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta7777 committed Feb 23, 2019
1 parent aadbc45 commit 46f1cc6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/librustc_mir/hair/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>(
let param_ty = ParamEnv::reveal_all().and(tcx.lift_to_global(&ty).unwrap());
let width = tcx.layout_of(param_ty).map_err(|_| LitToConstError::Reported)?.size;
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
let shift = 128 - width.bits();
let result = (n << shift) >> shift;
let result = truncate(n, width);
trace!("trunc result: {}", result);
Ok(ConstValue::Scalar(Scalar::Bits {
bits: result,
Expand Down

0 comments on commit 46f1cc6

Please sign in to comment.