about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNadrieril <nadrieril+git@gmail.com>2019-11-09 21:06:41 +0000
committerNadrieril <nadrieril+git@gmail.com>2019-11-15 16:44:34 +0000
commit019212420216a8a4ec6ec9c11cd14cab7e4f9b89 (patch)
tree8f80ef487be199a9c1a186bbe0d9767b4bdaa91f
parentd1642f1eb51c349c3caa940da43f0b5a51111011 (diff)
downloadrust-019212420216a8a4ec6ec9c11cd14cab7e4f9b89.tar.gz
rust-019212420216a8a4ec6ec9c11cd14cab7e4f9b89.zip
Make should_treat_range_exhaustively a method
-rw-r--r--src/librustc_mir/hair/pattern/_match.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index 090bcb8be16..e1cb847c68d 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -1282,11 +1282,10 @@ impl<'tcx> IntRange<'tcx> {
         (*self.range.start(), *self.range.end())
     }
 
-    fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
+    fn treat_exhaustively(&self, tcx: TyCtxt<'tcx>) -> bool {
         // Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
         // feature is enabled.
-        IntRange::is_integral(ty)
-            && (!ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching)
+        !self.ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching
     }
 
     #[inline]
@@ -1414,7 +1413,7 @@ impl<'tcx> IntRange<'tcx> {
         let ty = self.ty;
         let (lo, hi) = self.boundaries();
         let (other_lo, other_hi) = other.boundaries();
-        if Self::should_treat_range_exhaustively(tcx, ty) {
+        if self.treat_exhaustively(tcx) {
             if lo <= other_hi && other_lo <= hi {
                 let span = other.span;
                 Some(IntRange { range: max(lo, other_lo)..=min(hi, other_hi), ty, span })
@@ -1881,7 +1880,7 @@ fn split_grouped_constructors<'p, 'tcx>(
 
     for ctor in ctors.into_iter() {
         match ctor {
-            IntRange(ctor_range) if IntRange::should_treat_range_exhaustively(tcx, ty) => {
+            IntRange(ctor_range) if ctor_range.treat_exhaustively(tcx) => {
                 // Fast-track if the range is trivial. In particular, don't do the overlapping
                 // ranges check.
                 if ctor_range.is_singleton() {