@@ -33,15 +33,19 @@ pub(crate) struct PatternColumn<'p, 'tcx> {
3333
3434impl < ' p , ' tcx > PatternColumn < ' p , ' tcx > {
3535 pub ( crate ) fn new ( arms : & [ MatchArm < ' p , ' tcx > ] ) -> Self {
36- let mut patterns = Vec :: with_capacity ( arms. len ( ) ) ;
36+ let patterns = Vec :: with_capacity ( arms. len ( ) ) ;
37+ let mut column = PatternColumn { patterns } ;
3738 for arm in arms {
38- if arm. pat . is_or_pat ( ) {
39- patterns. extend ( arm. pat . flatten_or_pat ( ) )
40- } else {
41- patterns. push ( arm. pat )
42- }
39+ column. expand_and_push ( arm. pat ) ;
40+ }
41+ column
42+ }
43+ fn expand_and_push ( & mut self , pat : & ' p DeconstructedPat < ' p , ' tcx > ) {
44+ if pat. is_or_pat ( ) {
45+ self . patterns . extend ( pat. flatten_or_pat ( ) )
46+ } else {
47+ self . patterns . push ( pat)
4348 }
44- Self { patterns }
4549 }
4650
4751 fn is_empty ( & self ) -> bool {
@@ -87,11 +91,7 @@ impl<'p, 'tcx> PatternColumn<'p, 'tcx> {
8791 for pat in relevant_patterns {
8892 let specialized = pat. specialize ( pcx, ctor, ctor_sub_tys) ;
8993 for ( subpat, column) in specialized. iter ( ) . zip ( & mut specialized_columns) {
90- if subpat. is_or_pat ( ) {
91- column. patterns . extend ( subpat. flatten_or_pat ( ) )
92- } else {
93- column. patterns . push ( subpat)
94- }
94+ column. expand_and_push ( subpat) ;
9595 }
9696 }
9797
0 commit comments