@@ -1344,7 +1344,6 @@ fn collect_overlapping_range_endpoints<'p, Cx: TypeCx>(
1344
1344
overlap_range : IntRange ,
1345
1345
matrix : & Matrix < ' p , Cx > ,
1346
1346
specialized_matrix : & Matrix < ' p , Cx > ,
1347
- _overlapping_range_endpoints : & mut Vec < OverlappingRanges < ' p , Cx > > ,
1348
1347
) {
1349
1348
let overlap = overlap_range. lo ;
1350
1349
// Ranges that look like `lo..=overlap`.
@@ -1416,7 +1415,6 @@ fn collect_overlapping_range_endpoints<'p, Cx: TypeCx>(
1416
1415
fn compute_exhaustiveness_and_usefulness < ' a , ' p , Cx : TypeCx > (
1417
1416
mcx : MatchCtxt < ' a , Cx > ,
1418
1417
matrix : & mut Matrix < ' p , Cx > ,
1419
- overlapping_range_endpoints : & mut Vec < OverlappingRanges < ' p , Cx > > ,
1420
1418
is_top_level : bool ,
1421
1419
) -> Result < WitnessMatrix < Cx > , Cx :: Error > {
1422
1420
debug_assert ! ( matrix. rows( ) . all( |r| r. len( ) == matrix. column_count( ) ) ) ;
@@ -1496,12 +1494,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1496
1494
let ctor_is_relevant = matches ! ( ctor, Constructor :: Missing ) || missing_ctors. is_empty ( ) ;
1497
1495
let mut spec_matrix = matrix. specialize_constructor ( pcx, & ctor, ctor_is_relevant) ;
1498
1496
let mut witnesses = ensure_sufficient_stack ( || {
1499
- compute_exhaustiveness_and_usefulness (
1500
- mcx,
1501
- & mut spec_matrix,
1502
- overlapping_range_endpoints,
1503
- false ,
1504
- )
1497
+ compute_exhaustiveness_and_usefulness ( mcx, & mut spec_matrix, false )
1505
1498
} ) ?;
1506
1499
1507
1500
// Transform witnesses for `spec_matrix` into witnesses for `matrix`.
@@ -1530,13 +1523,7 @@ fn compute_exhaustiveness_and_usefulness<'a, 'p, Cx: TypeCx>(
1530
1523
&& spec_matrix. rows . len ( ) >= 2
1531
1524
&& spec_matrix. rows . iter ( ) . any ( |row| !row. intersects . is_empty ( ) )
1532
1525
{
1533
- collect_overlapping_range_endpoints (
1534
- mcx,
1535
- overlap_range,
1536
- matrix,
1537
- & spec_matrix,
1538
- overlapping_range_endpoints,
1539
- ) ;
1526
+ collect_overlapping_range_endpoints ( mcx, overlap_range, matrix, & spec_matrix) ;
1540
1527
}
1541
1528
}
1542
1529
}
@@ -1563,23 +1550,13 @@ pub enum Usefulness<'p, Cx: TypeCx> {
1563
1550
Redundant ,
1564
1551
}
1565
1552
1566
- /// Indicates that the range `pat` overlapped with all the ranges in `overlaps_with`, where the
1567
- /// range they overlapped over is `overlaps_on`. We only detect singleton overlaps.
1568
- #[ derive( Clone , Debug ) ]
1569
- pub struct OverlappingRanges < ' p , Cx : TypeCx > {
1570
- pub pat : & ' p DeconstructedPat < ' p , Cx > ,
1571
- pub overlaps_on : IntRange ,
1572
- pub overlaps_with : Vec < & ' p DeconstructedPat < ' p , Cx > > ,
1573
- }
1574
-
1575
1553
/// The output of checking a match for exhaustiveness and arm usefulness.
1576
1554
pub struct UsefulnessReport < ' p , Cx : TypeCx > {
1577
1555
/// For each arm of the input, whether that arm is useful after the arms above it.
1578
1556
pub arm_usefulness : Vec < ( MatchArm < ' p , Cx > , Usefulness < ' p , Cx > ) > ,
1579
1557
/// If the match is exhaustive, this is empty. If not, this contains witnesses for the lack of
1580
1558
/// exhaustiveness.
1581
1559
pub non_exhaustiveness_witnesses : Vec < WitnessPat < Cx > > ,
1582
- pub overlapping_range_endpoints : Vec < OverlappingRanges < ' p , Cx > > ,
1583
1560
}
1584
1561
1585
1562
/// Computes whether a match is exhaustive and which of its arms are useful.
@@ -1590,14 +1567,9 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
1590
1567
scrut_ty : Cx :: Ty ,
1591
1568
scrut_validity : ValidityConstraint ,
1592
1569
) -> Result < UsefulnessReport < ' p , Cx > , Cx :: Error > {
1593
- let mut overlapping_range_endpoints = Vec :: new ( ) ;
1594
1570
let mut matrix = Matrix :: new ( arms, scrut_ty, scrut_validity) ;
1595
- let non_exhaustiveness_witnesses = compute_exhaustiveness_and_usefulness (
1596
- cx,
1597
- & mut matrix,
1598
- & mut overlapping_range_endpoints,
1599
- true ,
1600
- ) ?;
1571
+ let non_exhaustiveness_witnesses =
1572
+ compute_exhaustiveness_and_usefulness ( cx, & mut matrix, true ) ?;
1601
1573
1602
1574
let non_exhaustiveness_witnesses: Vec < _ > = non_exhaustiveness_witnesses. single_column ( ) ;
1603
1575
let arm_usefulness: Vec < _ > = arms
@@ -1615,9 +1587,5 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
1615
1587
} )
1616
1588
. collect ( ) ;
1617
1589
1618
- Ok ( UsefulnessReport {
1619
- arm_usefulness,
1620
- non_exhaustiveness_witnesses,
1621
- overlapping_range_endpoints,
1622
- } )
1590
+ Ok ( UsefulnessReport { arm_usefulness, non_exhaustiveness_witnesses } )
1623
1591
}
0 commit comments