Skip to content

Commit 0192124

Browse files
committed
Make should_treat_range_exhaustively a method
1 parent d1642f1 commit 0192124

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,11 +1282,10 @@ impl<'tcx> IntRange<'tcx> {
12821282
(*self.range.start(), *self.range.end())
12831283
}
12841284

1285-
fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
1285+
fn treat_exhaustively(&self, tcx: TyCtxt<'tcx>) -> bool {
12861286
// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
12871287
// feature is enabled.
1288-
IntRange::is_integral(ty)
1289-
&& (!ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching)
1288+
!self.ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching
12901289
}
12911290

12921291
#[inline]
@@ -1414,7 +1413,7 @@ impl<'tcx> IntRange<'tcx> {
14141413
let ty = self.ty;
14151414
let (lo, hi) = self.boundaries();
14161415
let (other_lo, other_hi) = other.boundaries();
1417-
if Self::should_treat_range_exhaustively(tcx, ty) {
1416+
if self.treat_exhaustively(tcx) {
14181417
if lo <= other_hi && other_lo <= hi {
14191418
let span = other.span;
14201419
Some(IntRange { range: max(lo, other_lo)..=min(hi, other_hi), ty, span })
@@ -1881,7 +1880,7 @@ fn split_grouped_constructors<'p, 'tcx>(
18811880

18821881
for ctor in ctors.into_iter() {
18831882
match ctor {
1884-
IntRange(ctor_range) if IntRange::should_treat_range_exhaustively(tcx, ty) => {
1883+
IntRange(ctor_range) if ctor_range.treat_exhaustively(tcx) => {
18851884
// Fast-track if the range is trivial. In particular, don't do the overlapping
18861885
// ranges check.
18871886
if ctor_range.is_singleton() {

0 commit comments

Comments
 (0)