Skip to content

Commit

Permalink
Rollup merge of rust-lang#58667 - kenta7777:reduce-mir-code-repetitio…
Browse files Browse the repository at this point in the history
…n, r=petrochenkov

Reduce Miri-related 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 23, 2019
2 parents 6fa3116 + 42d5cf8 commit 6f374ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::hash::Hash;

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;
Expand Down Expand Up @@ -965,8 +966,7 @@ where
// 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)?;
Expand Down

0 comments on commit 6f374ea

Please sign in to comment.