reduced a code repetition related to bit operation.
This commit is contained in:
parent
70d1150478
commit
12e3e8412c
1 changed files with 3 additions and 4 deletions
|
@ -172,7 +172,7 @@ use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const};
|
|||
use rustc::ty::layout::{Integer, IntegerExt, VariantIdx, Size};
|
||||
|
||||
use rustc::mir::Field;
|
||||
use rustc::mir::interpret::{ConstValue, Scalar};
|
||||
use rustc::mir::interpret::{ConstValue, Scalar, truncate};
|
||||
use rustc::util::common::ErrorReported;
|
||||
|
||||
use syntax::attr::{SignedInt, UnsignedInt};
|
||||
|
@ -685,9 +685,8 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
|||
vec![ConstantRange(min, max, pcx.ty, RangeEnd::Included)]
|
||||
}
|
||||
ty::Uint(uty) => {
|
||||
// FIXME(49937): refactor these bit manipulations into interpret.
|
||||
let bits = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size().bits() as u128;
|
||||
let max = !0u128 >> (128 - bits);
|
||||
let size = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size();
|
||||
let max = truncate(u128::max_value(), size);
|
||||
vec![ConstantRange(0, max, pcx.ty, RangeEnd::Included)]
|
||||
}
|
||||
_ => {
|
||||
|
|
Loading…
Reference in a new issue