diff options
| author | kenta7777 <k.hasegw7@gmail.com> | 2019-03-15 21:48:05 +0900 |
|---|---|---|
| committer | kenta7777 <k.hasegw7@gmail.com> | 2019-03-15 21:48:05 +0900 |
| commit | 12e3e8412cd8eb1ec93034d52e4287dbae2027de (patch) | |
| tree | 50aac6582e99cc9947dcfdde1c4d2cc25e166a4e /src | |
| parent | 70d1150478c3d4f9b959f558cffc1863f1527654 (diff) | |
| download | rust-12e3e8412cd8eb1ec93034d52e4287dbae2027de.tar.gz rust-12e3e8412cd8eb1ec93034d52e4287dbae2027de.zip | |
reduced a code repetition related to bit operation.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/hair/pattern/_match.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 586a3fdb907..76e04d349f1 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -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)] } _ => { |
