未验证 提交 a36d1b93 编写于 作者: M Mazdak Farrokhzad 提交者: GitHub

Rollup merge of #58667 - kenta7777:reduce-mir-code-repetition, r=petrochenkov

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

This Pull Request fixes a part of [#49937](https://github.com/rust-lang/rust/issues/49937).
......@@ -7,6 +7,7 @@
use rustc::hir;
use rustc::mir;
use rustc::mir::interpret::truncate;
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, Size, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx};
use rustc::ty::TypeFoldable;
......@@ -965,8 +966,7 @@ pub fn write_discriminant_index(
// their computation, but the in-memory tag is the smallest possible
// representation
let size = tag.value.size(self);
let shift = 128 - size.bits();
let discr_val = (discr_val << shift) >> shift;
let discr_val = truncate(discr_val, size);
let discr_dest = self.place_field(dest, 0)?;
self.write_scalar(Scalar::from_uint(discr_val, size), discr_dest)?;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册