@@ -658,7 +658,6 @@ impl<'tcx> Constructor<'tcx> {
658658 // anything in `other_ctors`.
659659 fn subtract_ctors (
660660 & self ,
661- pcx : PatCtxt < ' tcx > ,
662661 tcx : TyCtxt < ' tcx > ,
663662 param_env : ty:: ParamEnv < ' tcx > ,
664663 other_ctors : & Vec < Constructor < ' tcx > > ,
@@ -681,11 +680,7 @@ impl<'tcx> Constructor<'tcx> {
681680 if other_ctors. iter ( ) . any ( overlaps) { vec ! [ ] } else { vec ! [ self . clone( ) ] }
682681 }
683682 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( ) ] ;
689684
690685 // For each used ctor, subtract from the current set of constructors.
691686 // Naming: we remove the "neg" constructors from the "pos" ones.
@@ -704,6 +699,23 @@ impl<'tcx> Constructor<'tcx> {
704699 smallvec ! [ pos_ctor]
705700 }
706701 }
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+ }
707719 _ if pos_ctor == * neg_ctor => smallvec ! [ ] ,
708720 _ => smallvec ! [ pos_ctor] ,
709721 }
@@ -1456,7 +1468,6 @@ impl<'tcx> IntRange<'tcx> {
14561468
14571469// A struct to compute a set of constructors equivalent to `all_ctors \ used_ctors`.
14581470struct MissingConstructors < ' tcx > {
1459- pcx : PatCtxt < ' tcx > ,
14601471 tcx : TyCtxt < ' tcx > ,
14611472 param_env : ty:: ParamEnv < ' tcx > ,
14621473 all_ctors : Vec < Constructor < ' tcx > > ,
@@ -1465,13 +1476,12 @@ struct MissingConstructors<'tcx> {
14651476
14661477impl < ' tcx > MissingConstructors < ' tcx > {
14671478 fn new (
1468- pcx : PatCtxt < ' tcx > ,
14691479 tcx : TyCtxt < ' tcx > ,
14701480 param_env : ty:: ParamEnv < ' tcx > ,
14711481 all_ctors : Vec < Constructor < ' tcx > > ,
14721482 used_ctors : Vec < Constructor < ' tcx > > ,
14731483 ) -> Self {
1474- MissingConstructors { pcx , tcx, param_env, all_ctors, used_ctors }
1484+ MissingConstructors { tcx, param_env, all_ctors, used_ctors }
14751485 }
14761486
14771487 fn into_inner ( self ) -> ( Vec < Constructor < ' tcx > > , Vec < Constructor < ' tcx > > ) {
@@ -1490,7 +1500,7 @@ impl<'tcx> MissingConstructors<'tcx> {
14901500 /// Iterate over all_ctors \ used_ctors
14911501 fn iter < ' a > ( & ' a self ) -> impl Iterator < Item = Constructor < ' tcx > > + Captures < ' a > {
14921502 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 )
14941504 } )
14951505 }
14961506}
@@ -1633,8 +1643,7 @@ pub fn is_useful<'p, 'a, 'tcx>(
16331643 // non-wildcard patterns in the current column. To determine if
16341644 // the set is empty, we can check that `.peek().is_none()`, so
16351645 // 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) ;
16381647
16391648 debug ! (
16401649 "missing_ctors.empty()={:#?} is_privately_empty={:#?} is_declared_nonexhaustive={:#?}" ,
0 commit comments