@@ -1231,6 +1231,10 @@ impl<'tcx> IntRange<'tcx> {
1231
1231
self . range . start ( ) == self . range . end ( )
1232
1232
}
1233
1233
1234
+ fn boundaries ( & self ) -> ( u128 , u128 ) {
1235
+ ( * self . range . start ( ) , * self . range . end ( ) )
1236
+ }
1237
+
1234
1238
fn should_treat_range_exhaustively ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> bool {
1235
1239
// Don't treat `usize`/`isize` exhaustively unless the `precise_pointer_size_matching`
1236
1240
// feature is enabled.
@@ -1341,11 +1345,11 @@ impl<'tcx> IntRange<'tcx> {
1341
1345
1342
1346
/// Returns a collection of ranges that spans the values covered by `ranges`, subtracted
1343
1347
/// by the values covered by `self`: i.e., `ranges \ self` (in set notation).
1344
- fn subtract_from ( self , ranges : Vec < IntRange < ' tcx > > ) -> Vec < IntRange < ' tcx > > {
1348
+ fn subtract_from ( & self , ranges : Vec < IntRange < ' tcx > > ) -> Vec < IntRange < ' tcx > > {
1345
1349
let mut remaining_ranges = vec ! [ ] ;
1346
1350
let ty = self . ty ;
1347
1351
let span = self . span ;
1348
- let ( lo, hi) = self . range . into_inner ( ) ;
1352
+ let ( lo, hi) = self . boundaries ( ) ;
1349
1353
for subrange in ranges {
1350
1354
let ( subrange_lo, subrange_hi) = subrange. range . into_inner ( ) ;
1351
1355
if lo > subrange_hi || subrange_lo > hi {
@@ -1370,8 +1374,8 @@ impl<'tcx> IntRange<'tcx> {
1370
1374
1371
1375
fn intersection ( & self , tcx : TyCtxt < ' tcx > , other : & Self ) -> Option < Self > {
1372
1376
let ty = self . ty ;
1373
- let ( lo, hi) = ( * self . range . start ( ) , * self . range . end ( ) ) ;
1374
- let ( other_lo, other_hi) = ( * other. range . start ( ) , * other . range . end ( ) ) ;
1377
+ let ( lo, hi) = self . boundaries ( ) ;
1378
+ let ( other_lo, other_hi) = other. boundaries ( ) ;
1375
1379
if Self :: should_treat_range_exhaustively ( tcx, ty) {
1376
1380
if lo <= other_hi && other_lo <= hi {
1377
1381
let span = other. span ;
@@ -1397,13 +1401,13 @@ impl<'tcx> IntRange<'tcx> {
1397
1401
// `true` in the following cases:
1398
1402
// 1 ------- // 1 -------
1399
1403
// 2 -------- // 2 -------
1400
- let ( lo, hi) = ( * self . range . start ( ) , * self . range . end ( ) ) ;
1401
- let ( other_lo, other_hi) = ( * other. range . start ( ) , * other . range . end ( ) ) ;
1404
+ let ( lo, hi) = self . boundaries ( ) ;
1405
+ let ( other_lo, other_hi) = other. boundaries ( ) ;
1402
1406
( lo == other_hi || hi == other_lo)
1403
1407
}
1404
1408
1405
1409
fn to_pat ( & self , tcx : TyCtxt < ' tcx > ) -> Pat < ' tcx > {
1406
- let ( lo, hi) = ( self . range . start ( ) , self . range . end ( ) ) ;
1410
+ let ( lo, hi) = self . boundaries ( ) ;
1407
1411
1408
1412
let bias = IntRange :: signed_bias ( tcx, self . ty ) ;
1409
1413
let ( lo, hi) = ( lo ^ bias, hi ^ bias) ;
@@ -2278,8 +2282,8 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
2278
2282
( Some ( ctor) , Some ( pat) ) => ctor. intersection ( cx. tcx , & pat) . map ( |_| {
2279
2283
// Constructor splitting should ensure that all intersections we encounter
2280
2284
// are actually inclusions.
2281
- let ( pat_lo, pat_hi) = pat. range . into_inner ( ) ;
2282
- let ( ctor_lo, ctor_hi) = ctor. range . into_inner ( ) ;
2285
+ let ( pat_lo, pat_hi) = pat. boundaries ( ) ;
2286
+ let ( ctor_lo, ctor_hi) = ctor. boundaries ( ) ;
2283
2287
assert ! ( pat_lo <= ctor_lo && ctor_hi <= pat_hi) ;
2284
2288
PatStack :: default ( )
2285
2289
} ) ,
0 commit comments