From 4c9f7a08e5a92745772eb50b3c8f0612cc476c6b Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 11 Mar 2019 22:32:27 +0900 Subject: [PATCH] reduced some code repetitions of bit operation --- src/librustc_mir/build/matches/simplify.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index 01f8cbfbe8e2b..a691924682520 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -19,6 +19,7 @@ use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; use syntax::attr::{SignedInt, UnsignedInt}; use rustc::hir::RangeEnd; +use rustc::mir::interpret::mask; use std::mem; @@ -115,14 +116,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ty::Int(ity) => { // FIXME(49937): refactor these bit manipulations into interpret. let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); - let max = !0u128 >> (128 - size.bits()); + let max = mask(size); let bias = 1u128 << (size.bits() - 1); (Some((0, max, size)), bias) } ty::Uint(uty) => { // FIXME(49937): refactor these bit manipulations into interpret. let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size(); - let max = !0u128 >> (128 - size.bits()); + let max = mask(size); (Some((0, max, size)), 0) } _ => (None, 0),