Skip to content

Commit 4b4e6bd

Browse files
committed
Make should_treat_range_exhaustively a method
1 parent eafc9db commit 4b4e6bd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/librustc_mir/hair/pattern/_match.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1230,11 +1230,10 @@ impl<'tcx> IntRange<'tcx> {
12301230
(*self.range.start(), *self.range.end())
12311231
}
12321232

1233-
fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
1233+
fn treat_exhaustively(&self, tcx: TyCtxt<'tcx>) -> bool {
12341234
// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
12351235
// feature is enabled.
1236-
IntRange::is_integral(ty)
1237-
&& (!ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching)
1236+
!self.ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching
12381237
}
12391238

12401239
#[inline]
@@ -1360,7 +1359,7 @@ impl<'tcx> IntRange<'tcx> {
13601359
let ty = self.ty;
13611360
let (lo, hi) = self.boundaries();
13621361
let (other_lo, other_hi) = other.boundaries();
1363-
if Self::should_treat_range_exhaustively(tcx, ty) {
1362+
if self.treat_exhaustively(tcx) {
13641363
if lo <= other_hi && other_lo <= hi {
13651364
let span = other.span;
13661365
Some(IntRange { range: max(lo, other_lo)..=min(hi, other_hi), ty, span })
@@ -1858,7 +1857,7 @@ fn split_grouped_constructors<'p, 'tcx>(
18581857

18591858
for ctor in ctors.into_iter() {
18601859
match ctor {
1861-
IntRange(ctor_range) if IntRange::should_treat_range_exhaustively(tcx, ty) => {
1860+
IntRange(ctor_range) if ctor_range.treat_exhaustively(tcx) => {
18621861
// Fast-track if the range is trivial. In particular, don't do the overlapping
18631862
// ranges check.
18641863
if ctor_range.is_singleton() {

0 commit comments

Comments
 (0)