Skip to content

Commit 12e3e84

Browse files
committed
reduced a code repetition related to bit operation.
1 parent 70d1150 commit 12e3e84

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/librustc_mir/hair/pattern/_match.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const};
172172
use rustc::ty::layout::{Integer, IntegerExt, VariantIdx, Size};
173173

174174
use rustc::mir::Field;
175-
use rustc::mir::interpret::{ConstValue, Scalar};
175+
use rustc::mir::interpret::{ConstValue, Scalar, truncate};
176176
use rustc::util::common::ErrorReported;
177177

178178
use syntax::attr::{SignedInt, UnsignedInt};
@@ -685,9 +685,8 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
685685
vec![ConstantRange(min, max, pcx.ty, RangeEnd::Included)]
686686
}
687687
ty::Uint(uty) => {
688-
// FIXME(49937): refactor these bit manipulations into interpret.
689-
let bits = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size().bits() as u128;
690-
let max = !0u128 >> (128 - bits);
688+
let size = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size();
689+
let max = truncate(u128::max_value(), size);
691690
vec![ConstantRange(0, max, pcx.ty, RangeEnd::Included)]
692691
}
693692
_ => {

0 commit comments

Comments
 (0)