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:
commit
5f910fa99c
1 changed files with 1 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue