@@ -658,7 +658,6 @@ impl<'tcx> Constructor<'tcx> {
658
658
// anything in `other_ctors`.
659
659
fn subtract_ctors (
660
660
& self ,
661
- pcx : PatCtxt < ' tcx > ,
662
661
tcx : TyCtxt < ' tcx > ,
663
662
param_env : ty:: ParamEnv < ' tcx > ,
664
663
other_ctors : & Vec < Constructor < ' tcx > > ,
@@ -681,11 +680,7 @@ impl<'tcx> Constructor<'tcx> {
681
680
if other_ctors. iter ( ) . any ( overlaps) { vec ! [ ] } else { vec ! [ self . clone( ) ] }
682
681
}
683
682
VarLenSlice ( _) => {
684
- let mut remaining_ctors = if let VarLenSlice ( len) = self {
685
- ( * len..pcx. max_slice_length + 1 ) . map ( FixedLenSlice ) . collect ( )
686
- } else {
687
- vec ! [ self . clone( ) ]
688
- } ;
683
+ let mut remaining_ctors = vec ! [ self . clone( ) ] ;
689
684
690
685
// For each used ctor, subtract from the current set of constructors.
691
686
// Naming: we remove the "neg" constructors from the "pos" ones.
@@ -704,6 +699,23 @@ impl<'tcx> Constructor<'tcx> {
704
699
smallvec ! [ pos_ctor]
705
700
}
706
701
}
702
+ ( VarLenSlice ( pos_len) , VarLenSlice ( neg_len) ) => {
703
+ if neg_len <= pos_len {
704
+ smallvec ! [ ]
705
+ } else {
706
+ ( * pos_len..* neg_len) . map ( FixedLenSlice ) . collect ( )
707
+ }
708
+ }
709
+ ( VarLenSlice ( pos_len) , FixedLenSlice ( neg_len) ) => {
710
+ if neg_len < pos_len {
711
+ smallvec ! [ pos_ctor]
712
+ } else {
713
+ ( * pos_len..* neg_len)
714
+ . map ( FixedLenSlice )
715
+ . chain ( Some ( VarLenSlice ( neg_len + 1 ) ) )
716
+ . collect ( )
717
+ }
718
+ }
707
719
_ if pos_ctor == * neg_ctor => smallvec ! [ ] ,
708
720
_ => smallvec ! [ pos_ctor] ,
709
721
}
@@ -1456,7 +1468,6 @@ impl<'tcx> IntRange<'tcx> {
1456
1468
1457
1469
// A struct to compute a set of constructors equivalent to `all_ctors \ used_ctors`.
1458
1470
struct MissingConstructors < ' tcx > {
1459
- pcx : PatCtxt < ' tcx > ,
1460
1471
tcx : TyCtxt < ' tcx > ,
1461
1472
param_env : ty:: ParamEnv < ' tcx > ,
1462
1473
all_ctors : Vec < Constructor < ' tcx > > ,
@@ -1465,13 +1476,12 @@ struct MissingConstructors<'tcx> {
1465
1476
1466
1477
impl < ' tcx > MissingConstructors < ' tcx > {
1467
1478
fn new (
1468
- pcx : PatCtxt < ' tcx > ,
1469
1479
tcx : TyCtxt < ' tcx > ,
1470
1480
param_env : ty:: ParamEnv < ' tcx > ,
1471
1481
all_ctors : Vec < Constructor < ' tcx > > ,
1472
1482
used_ctors : Vec < Constructor < ' tcx > > ,
1473
1483
) -> Self {
1474
- MissingConstructors { pcx , tcx, param_env, all_ctors, used_ctors }
1484
+ MissingConstructors { tcx, param_env, all_ctors, used_ctors }
1475
1485
}
1476
1486
1477
1487
fn into_inner ( self ) -> ( Vec < Constructor < ' tcx > > , Vec < Constructor < ' tcx > > ) {
@@ -1490,7 +1500,7 @@ impl<'tcx> MissingConstructors<'tcx> {
1490
1500
/// Iterate over all_ctors \ used_ctors
1491
1501
fn iter < ' a > ( & ' a self ) -> impl Iterator < Item = Constructor < ' tcx > > + Captures < ' a > {
1492
1502
self . all_ctors . iter ( ) . flat_map ( move |req_ctor| {
1493
- req_ctor. subtract_ctors ( self . pcx , self . tcx , self . param_env , & self . used_ctors )
1503
+ req_ctor. subtract_ctors ( self . tcx , self . param_env , & self . used_ctors )
1494
1504
} )
1495
1505
}
1496
1506
}
@@ -1633,8 +1643,7 @@ pub fn is_useful<'p, 'a, 'tcx>(
1633
1643
// non-wildcard patterns in the current column. To determine if
1634
1644
// the set is empty, we can check that `.peek().is_none()`, so
1635
1645
// we only fully construct them on-demand, because they're rarely used and can be big.
1636
- let missing_ctors =
1637
- MissingConstructors :: new ( pcx, cx. tcx , cx. param_env , all_ctors, used_ctors) ;
1646
+ let missing_ctors = MissingConstructors :: new ( cx. tcx , cx. param_env , all_ctors, used_ctors) ;
1638
1647
1639
1648
debug ! (
1640
1649
"missing_ctors.empty()={:#?} is_privately_empty={:#?} is_declared_nonexhaustive={:#?}" ,
0 commit comments