@@ -717,7 +717,7 @@ use std::fmt;
717
717
718
718
use crate :: constructor:: { Constructor , ConstructorSet } ;
719
719
use crate :: pat:: { DeconstructedPat , PatOrWild , WitnessPat } ;
720
- use crate :: { Captures , MatchArm , MatchCtxt , TypeCx , TypedArena } ;
720
+ use crate :: { Captures , MatchArm , MatchCtxt , TypeCx } ;
721
721
722
722
use self :: ValidityConstraint :: * ;
723
723
@@ -869,14 +869,13 @@ impl<'p, Cx: TypeCx> PatStack<'p, Cx> {
869
869
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
870
870
fn pop_head_constructor (
871
871
& self ,
872
- pcx : & PlaceCtxt < ' _ , ' p , Cx > ,
873
872
ctor : & Constructor < Cx > ,
874
- ctor_sub_tys : & [ Cx :: Ty ] ,
873
+ ctor_arity : usize ,
875
874
ctor_is_relevant : bool ,
876
875
) -> PatStack < ' p , Cx > {
877
876
// We pop the head pattern and push the new fields extracted from the arguments of
878
877
// `self.head()`.
879
- let mut new_pats = self . head ( ) . specialize ( pcx , ctor, ctor_sub_tys ) ;
878
+ let mut new_pats = self . head ( ) . specialize ( ctor, ctor_arity ) ;
880
879
new_pats. extend_from_slice ( & self . pats [ 1 ..] ) ;
881
880
// `ctor` is relevant for this row if it is the actual constructor of this row, or if the
882
881
// row has a wildcard and `ctor` is relevant for wildcards.
@@ -946,14 +945,13 @@ impl<'p, Cx: TypeCx> MatrixRow<'p, Cx> {
946
945
/// Only call if `ctor.is_covered_by(self.head().ctor())` is true.
947
946
fn pop_head_constructor (
948
947
& self ,
949
- pcx : & PlaceCtxt < ' _ , ' p , Cx > ,
950
948
ctor : & Constructor < Cx > ,
951
- ctor_sub_tys : & [ Cx :: Ty ] ,
949
+ ctor_arity : usize ,
952
950
ctor_is_relevant : bool ,
953
951
parent_row : usize ,
954
952
) -> MatrixRow < ' p , Cx > {
955
953
MatrixRow {
956
- pats : self . pats . pop_head_constructor ( pcx , ctor, ctor_sub_tys , ctor_is_relevant) ,
954
+ pats : self . pats . pop_head_constructor ( ctor, ctor_arity , ctor_is_relevant) ,
957
955
parent_row,
958
956
is_under_guard : self . is_under_guard ,
959
957
useful : false ,
@@ -1008,7 +1006,6 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
1008
1006
1009
1007
/// Build a new matrix from an iterator of `MatchArm`s.
1010
1008
fn new (
1011
- wildcard_arena : & ' p TypedArena < DeconstructedPat < ' p , Cx > > ,
1012
1009
arms : & [ MatchArm < ' p , Cx > ] ,
1013
1010
scrut_ty : Cx :: Ty ,
1014
1011
scrut_validity : ValidityConstraint ,
@@ -1063,11 +1060,12 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
1063
1060
ctor : & Constructor < Cx > ,
1064
1061
ctor_is_relevant : bool ,
1065
1062
) -> Matrix < ' p , Cx > {
1066
- let tys = pcx. ctor_sub_tys ( ctor) ;
1067
- let new_place_ty = tys. iter ( ) . chain ( self . place_ty [ 1 ..] . iter ( ) ) . copied ( ) . collect ( ) ;
1068
- let new_validity = self . place_validity [ 0 ] . specialize ( ctor) ;
1069
- let new_place_validity = std:: iter:: repeat ( new_validity)
1070
- . take ( ctor. arity ( pcx) )
1063
+ let ctor_sub_tys = pcx. ctor_sub_tys ( ctor) ;
1064
+ let arity = ctor_sub_tys. len ( ) ;
1065
+ let new_place_ty = ctor_sub_tys. iter ( ) . chain ( self . place_ty [ 1 ..] . iter ( ) ) . copied ( ) . collect ( ) ;
1066
+ let ctor_sub_validity = self . place_validity [ 0 ] . specialize ( ctor) ;
1067
+ let new_place_validity = std:: iter:: repeat ( ctor_sub_validity)
1068
+ . take ( arity)
1071
1069
. chain ( self . place_validity [ 1 ..] . iter ( ) . copied ( ) )
1072
1070
. collect ( ) ;
1073
1071
let mut matrix = Matrix {
@@ -1078,7 +1076,7 @@ impl<'p, Cx: TypeCx> Matrix<'p, Cx> {
1078
1076
} ;
1079
1077
for ( i, row) in self . rows ( ) . enumerate ( ) {
1080
1078
if ctor. is_covered_by ( pcx, row. head ( ) . ctor ( ) ) {
1081
- let new_row = row. pop_head_constructor ( pcx , ctor, tys , ctor_is_relevant, i) ;
1079
+ let new_row = row. pop_head_constructor ( ctor, arity , ctor_is_relevant, i) ;
1082
1080
matrix. expand_and_push ( new_row) ;
1083
1081
}
1084
1082
}
@@ -1471,7 +1469,7 @@ pub fn compute_match_usefulness<'p, Cx: TypeCx>(
1471
1469
scrut_ty : Cx :: Ty ,
1472
1470
scrut_validity : ValidityConstraint ,
1473
1471
) -> UsefulnessReport < ' p , Cx > {
1474
- let mut matrix = Matrix :: new ( cx . wildcard_arena , arms, scrut_ty, scrut_validity) ;
1472
+ let mut matrix = Matrix :: new ( arms, scrut_ty, scrut_validity) ;
1475
1473
let non_exhaustiveness_witnesses = compute_exhaustiveness_and_usefulness ( cx, & mut matrix, true ) ;
1476
1474
1477
1475
let non_exhaustiveness_witnesses: Vec < _ > = non_exhaustiveness_witnesses. single_column ( ) ;
0 commit comments