@@ -1283,6 +1283,10 @@ impl<'tcx> IntRange<'tcx> {
1283
1283
self . range . start ( ) == self . range . end ( )
1284
1284
}
1285
1285
1286
+ fn boundaries ( & self ) -> ( u128 , u128 ) {
1287
+ ( * self . range . start ( ) , * self . range . end ( ) )
1288
+ }
1289
+
1286
1290
fn should_treat_range_exhaustively ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> bool {
1287
1291
// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
1288
1292
// feature is enabled.
@@ -1395,11 +1399,11 @@ impl<'tcx> IntRange<'tcx> {
1395
1399
1396
1400
/// Returns a collection of ranges that spans the values covered by `ranges`, subtracted
1397
1401
/// by the values covered by `self`: i.e., `ranges \ self` (in set notation).
1398
- fn subtract_from ( self , ranges : Vec < IntRange < ' tcx > > ) -> Vec < IntRange < ' tcx > > {
1402
+ fn subtract_from ( & self , ranges : Vec < IntRange < ' tcx > > ) -> Vec < IntRange < ' tcx > > {
1399
1403
let mut remaining_ranges = vec ! [ ] ;
1400
1404
let ty = self . ty ;
1401
1405
let span = self . span ;
1402
- let ( lo, hi) = self . range . into_inner ( ) ;
1406
+ let ( lo, hi) = self . boundaries ( ) ;
1403
1407
for subrange in ranges {
1404
1408
let ( subrange_lo, subrange_hi) = subrange. range . into_inner ( ) ;
1405
1409
if lo > subrange_hi || subrange_lo > hi {
@@ -1424,8 +1428,8 @@ impl<'tcx> IntRange<'tcx> {
1424
1428
1425
1429
fn intersection ( & self , tcx : TyCtxt < ' tcx > , other : & Self ) -> Option < Self > {
1426
1430
let ty = self . ty ;
1427
- let ( lo, hi) = ( * self . range . start ( ) , * self . range . end ( ) ) ;
1428
- let ( other_lo, other_hi) = ( * other. range . start ( ) , * other . range . end ( ) ) ;
1431
+ let ( lo, hi) = self . boundaries ( ) ;
1432
+ let ( other_lo, other_hi) = other. boundaries ( ) ;
1429
1433
if Self :: should_treat_range_exhaustively ( tcx, ty) {
1430
1434
if lo <= other_hi && other_lo <= hi {
1431
1435
let span = other. span ;
@@ -1451,13 +1455,13 @@ impl<'tcx> IntRange<'tcx> {
1451
1455
// `true` in the following cases:
1452
1456
// 1 ------- // 1 -------
1453
1457
// 2 -------- // 2 -------
1454
- let ( lo, hi) = ( * self . range . start ( ) , * self . range . end ( ) ) ;
1455
- let ( other_lo, other_hi) = ( * other. range . start ( ) , * other . range . end ( ) ) ;
1458
+ let ( lo, hi) = self . boundaries ( ) ;
1459
+ let ( other_lo, other_hi) = other. boundaries ( ) ;
1456
1460
( lo == other_hi || hi == other_lo)
1457
1461
}
1458
1462
1459
1463
fn to_pat ( & self , tcx : TyCtxt < ' tcx > ) -> Pat < ' tcx > {
1460
- let ( lo, hi) = ( self . range . start ( ) , self . range . end ( ) ) ;
1464
+ let ( lo, hi) = self . boundaries ( ) ;
1461
1465
1462
1466
let bias = IntRange :: signed_bias ( tcx, self . ty ) ;
1463
1467
let ( lo, hi) = ( lo ^ bias, hi ^ bias) ;
@@ -2309,8 +2313,8 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
2309
2313
( Some ( ctor) , Some ( pat) ) => ctor. intersection ( cx. tcx , & pat) . map ( |_| {
2310
2314
// Constructor splitting should ensure that all intersections we encounter
2311
2315
// are actually inclusions.
2312
- let ( pat_lo, pat_hi) = pat. range . into_inner ( ) ;
2313
- let ( ctor_lo, ctor_hi) = ctor. range . into_inner ( ) ;
2316
+ let ( pat_lo, pat_hi) = pat. boundaries ( ) ;
2317
+ let ( ctor_lo, ctor_hi) = ctor. boundaries ( ) ;
2314
2318
assert ! ( pat_lo <= ctor_lo && ctor_hi <= pat_hi) ;
2315
2319
PatStack :: default ( )
2316
2320
} ) ,
0 commit comments