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](https://github.com/rust-lang/rust/issues/49937).
This commit is contained in:
Mazdak Farrokhzad 2019-02-25 11:42:20 +01:00 committed by GitHub
commit 5f910fa99c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,