diff options
| author | varkor <github@varkor.com> | 2018-05-24 13:30:21 +0100 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-08-16 20:09:05 +0100 |
| commit | 1aa749469bfc57ae023be6fbb1141b806bcb3d62 (patch) | |
| tree | 4d3a89c41dd5679d22ef3dbffd5fa76930c36453 | |
| parent | 72cc4bd33b0d1b975173f4032581040fa354b724 (diff) | |
| download | rust-1aa749469bfc57ae023be6fbb1141b806bcb3d62.tar.gz rust-1aa749469bfc57ae023be6fbb1141b806bcb3d62.zip | |
Introduce signed_bias method
The epitome of simplicity!
| -rw-r--r-- | src/librustc_mir/hair/pattern/_match.rs | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index e498b5582bf..0d56f345d8e 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -21,11 +21,13 @@ use super::{PatternFoldable, PatternFolder, compare_const_vals}; use rustc::hir::def_id::DefId; use rustc::hir::RangeEnd; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::layout::{Integer, IntegerExt}; use rustc::mir::Field; use rustc::mir::interpret::ConstValue; use rustc::util::common::ErrorReported; +use syntax::attr::{SignedInt, UnsignedInt}; use syntax_pos::{Span, DUMMY_SP}; use arena::TypedArena; @@ -469,10 +471,9 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ConstantRange(endpoint('\u{E000}'), endpoint('\u{10FFFF}'), RangeEnd::Included), ] } - ty::TyInt(_) if exhaustive_integer_patterns => { + ty::TyInt(ity) if exhaustive_integer_patterns => { // FIXME(49937): refactor these bit manipulations into interpret. - let bits = cx.tcx.layout_of(ty::ParamEnv::reveal_all().and(pcx.ty)) - .unwrap().size.bits() as u128; + let bits = Integer::from_attr(cx.tcx, SignedInt(ity)).size().bits() as u128; let min = 1u128 << (bits - 1); let max = (1u128 << (bits - 1)) - 1; value_constructors = true; @@ -480,10 +481,9 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, ty::Const::from_bits(cx.tcx, max as u128, pcx.ty), RangeEnd::Included)] } - ty::TyUint(_) if exhaustive_integer_patterns => { + ty::TyUint(uty) if exhaustive_integer_patterns => { // FIXME(49937): refactor these bit manipulations into interpret. - let bits = cx.tcx.layout_of(ty::ParamEnv::reveal_all().and(pcx.ty)) - .unwrap().size.bits() as u128; + let bits = Integer::from_attr(cx.tcx, UnsignedInt(uty)).size().bits() as u128; let max = !0u128 >> (128 - bits); value_constructors = true; vec