Skip to content

Commit

Permalink
Rollup merge of rust-lang#58687 - kenta7777:reduce-miri-code-repetiti…
Browse files Browse the repository at this point in the history
…on, r=oli-obk

Reduce Miri Code Repetition like `(n << amt) >> amt`

This Pull Request fixes a part of [rust-lang#49937](rust-lang#49937).
  • Loading branch information
Centril authored Feb 25, 2019
2 parents 554aed6 + 46f1cc6 commit 5f910fa
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 5f910fa

Please sign in to comment.