@@ -301,7 +301,7 @@ use rustc_span::Span;
301301
302302use smallvec:: { smallvec, SmallVec } ;
303303use std:: fmt;
304- use std:: iter:: { FromIterator , IntoIterator } ;
304+ use std:: iter:: IntoIterator ;
305305use std:: lazy:: OnceCell ;
306306
307307crate struct MatchCheckCtxt < ' a , ' tcx > {
@@ -489,15 +489,6 @@ impl<'p, 'tcx> PartialEq for PatStack<'p, 'tcx> {
489489 }
490490}
491491
492- impl < ' p , ' tcx > FromIterator < & ' p Pat < ' tcx > > for PatStack < ' p , ' tcx > {
493- fn from_iter < T > ( iter : T ) -> Self
494- where
495- T : IntoIterator < Item = & ' p Pat < ' tcx > > ,
496- {
497- Self :: from_vec ( iter. into_iter ( ) . collect ( ) )
498- }
499- }
500-
501492/// Pretty-printing for matrix row.
502493impl < ' p , ' tcx > fmt:: Debug for PatStack < ' p , ' tcx > {
503494 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -565,11 +556,14 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
565556 ctor : & Constructor < ' tcx > ,
566557 ctor_wild_subpatterns : & Fields < ' p , ' tcx > ,
567558 ) -> Matrix < ' p , ' tcx > {
568- self . patterns
569- . iter ( )
570- . filter ( |r| ctor. is_covered_by ( pcx, r. head_ctor ( pcx. cx ) ) )
571- . map ( |r| r. pop_head_constructor ( ctor_wild_subpatterns) )
572- . collect ( )
559+ let mut matrix = Matrix :: empty ( ) ;
560+ for row in & self . patterns {
561+ if ctor. is_covered_by ( pcx, row. head_ctor ( pcx. cx ) ) {
562+ let new_row = row. pop_head_constructor ( ctor_wild_subpatterns) ;
563+ matrix. push ( new_row) ;
564+ }
565+ }
566+ matrix
573567 }
574568}
575569
@@ -609,20 +603,6 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
609603 }
610604}
611605
612- impl < ' p , ' tcx > FromIterator < PatStack < ' p , ' tcx > > for Matrix < ' p , ' tcx > {
613- fn from_iter < T > ( iter : T ) -> Self
614- where
615- T : IntoIterator < Item = PatStack < ' p , ' tcx > > ,
616- {
617- let mut matrix = Matrix :: empty ( ) ;
618- for x in iter {
619- // Using `push` ensures we correctly expand or-patterns.
620- matrix. push ( x) ;
621- }
622- matrix
623- }
624- }
625-
626606/// Given a pattern or a pattern-stack, this struct captures a set of its subpatterns. We use that
627607/// to track reachable sub-patterns arising from or-patterns. In the absence of or-patterns this
628608/// will always be either `Empty` (the whole pattern is unreachable) or `Full` (the whole pattern
0 commit comments