diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 090bcb8be16a..e1cb847c68de 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() {