@@ -301,7 +301,7 @@ use rustc_span::Span;
301
301
302
302
use smallvec:: { smallvec, SmallVec } ;
303
303
use std:: fmt;
304
- use std:: iter:: { FromIterator , IntoIterator } ;
304
+ use std:: iter:: IntoIterator ;
305
305
use std:: lazy:: OnceCell ;
306
306
307
307
crate struct MatchCheckCtxt < ' a , ' tcx > {
@@ -489,15 +489,6 @@ impl<'p, 'tcx> PartialEq for PatStack<'p, 'tcx> {
489
489
}
490
490
}
491
491
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
-
501
492
/// Pretty-printing for matrix row.
502
493
impl < ' p , ' tcx > fmt:: Debug for PatStack < ' p , ' tcx > {
503
494
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -565,11 +556,14 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> {
565
556
ctor : & Constructor < ' tcx > ,
566
557
ctor_wild_subpatterns : & Fields < ' p , ' tcx > ,
567
558
) -> 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
573
567
}
574
568
}
575
569
@@ -609,20 +603,6 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
609
603
}
610
604
}
611
605
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
-
626
606
/// Given a pattern or a pattern-stack, this struct captures a set of its subpatterns. We use that
627
607
/// to track reachable sub-patterns arising from or-patterns. In the absence of or-patterns this
628
608
/// will always be either `Empty` (the whole pattern is unreachable) or `Full` (the whole pattern
0 commit comments