@@ -183,14 +183,6 @@ impl IntRange {
183183 Pat { ty, span : DUMMY_SP , kind : Box :: new ( kind) }
184184 }
185185
186- /// Split this range, as described at the top of the file.
187- fn split < ' p , ' tcx > ( & self , pcx : PatCtxt < ' _ , ' p , ' tcx > ) -> SmallVec < [ Constructor < ' tcx > ; 1 ] > {
188- let mut split_range = SplitIntRange :: new ( self . clone ( ) ) ;
189- let intranges = pcx. matrix . head_ctors ( pcx. cx ) . filter_map ( |ctor| ctor. as_int_range ( ) ) ;
190- split_range. split ( intranges. cloned ( ) ) ;
191- split_range. iter ( ) . map ( IntRange ) . collect ( )
192- }
193-
194186 /// Lint on likely incorrect range patterns (#63987)
195187 pub ( super ) fn lint_overlapping_range_endpoints ( & self , pcx : PatCtxt < ' _ , ' _ , ' _ > , hir_id : HirId ) {
196188 if self . is_singleton ( ) {
@@ -403,19 +395,6 @@ impl Slice {
403395 self . kind . arity ( )
404396 }
405397
406- /// Split this slice, as described at the top of the file.
407- fn split < ' p , ' tcx > ( self , pcx : PatCtxt < ' _ , ' p , ' tcx > ) -> SmallVec < [ Constructor < ' tcx > ; 1 ] > {
408- let ( self_prefix, self_suffix) = match self . kind {
409- VarLen ( self_prefix, self_suffix) => ( self_prefix, self_suffix) ,
410- _ => return smallvec ! [ Slice ( self ) ] ,
411- } ;
412-
413- let mut split_self = SplitVarLenSlice :: new ( self_prefix, self_suffix, self . array_len ) ;
414- let slices = pcx. matrix . head_ctors ( pcx. cx ) . filter_map ( |c| c. as_slice ( ) ) . map ( |s| s. kind ) ;
415- split_self. split ( slices) ;
416- split_self. iter ( ) . map ( Slice ) . collect ( )
417- }
418-
419398 /// See `Constructor::is_covered_by`
420399 fn is_covered_by ( self , other : Self ) -> bool {
421400 other. kind . covers_length ( self . arity ( ) )
@@ -680,26 +659,32 @@ impl<'tcx> Constructor<'tcx> {
680659 debug ! ( "Constructor::split({:#?}, {:#?})" , self , pcx. matrix) ;
681660
682661 match self {
683- Wildcard => Constructor :: split_wildcard ( pcx) ,
662+ Wildcard => {
663+ let mut split_wildcard = SplitWildcard :: new ( pcx) ;
664+ split_wildcard. split ( pcx) ;
665+ split_wildcard. into_ctors ( pcx)
666+ }
684667 // Fast-track if the range is trivial. In particular, we don't do the overlapping
685668 // ranges check.
686- IntRange ( ctor_range) if !ctor_range. is_singleton ( ) => ctor_range. split ( pcx) ,
687- Slice ( slice @ Slice { kind : VarLen ( ..) , .. } ) => slice. split ( pcx) ,
669+ IntRange ( ctor_range) if !ctor_range. is_singleton ( ) => {
670+ let mut split_range = SplitIntRange :: new ( ctor_range. clone ( ) ) ;
671+ let intranges =
672+ pcx. matrix . head_ctors ( pcx. cx ) . filter_map ( |ctor| ctor. as_int_range ( ) ) ;
673+ split_range. split ( intranges. cloned ( ) ) ;
674+ split_range. iter ( ) . map ( IntRange ) . collect ( )
675+ }
676+ & Slice ( Slice { kind : VarLen ( self_prefix, self_suffix) , array_len } ) => {
677+ let mut split_self = SplitVarLenSlice :: new ( self_prefix, self_suffix, array_len) ;
678+ let slices =
679+ pcx. matrix . head_ctors ( pcx. cx ) . filter_map ( |c| c. as_slice ( ) ) . map ( |s| s. kind ) ;
680+ split_self. split ( slices) ;
681+ split_self. iter ( ) . map ( Slice ) . collect ( )
682+ }
688683 // Any other constructor can be used unchanged.
689684 _ => smallvec ! [ self . clone( ) ] ,
690685 }
691686 }
692687
693- /// For wildcards, there are two groups of constructors: there are the constructors actually
694- /// present in the matrix (`head_ctors`), and the constructors not present (`missing_ctors`).
695- /// Two constructors that are not in the matrix will either both be caught (by a wildcard), or
696- /// both not be caught. Therefore we can keep the missing constructors grouped together.
697- fn split_wildcard < ' p > ( pcx : PatCtxt < ' _ , ' p , ' tcx > ) -> SmallVec < [ Self ; 1 ] > {
698- let mut split_wildcard = SplitWildcard :: new ( pcx) ;
699- split_wildcard. split ( pcx) ;
700- split_wildcard. into_ctors ( pcx)
701- }
702-
703688 /// Returns whether `self` is covered by `other`, i.e. whether `self` is a subset of `other`.
704689 /// For the simple cases, this is simply checking for equality. For the "grouped" constructors,
705690 /// this checks for inclusion.
0 commit comments