@@ -826,17 +826,17 @@ impl fmt::Display for ValidityConstraint {
826
826
// - Cx global compilation context
827
827
#[ derive( derivative:: Derivative ) ]
828
828
#[ derivative( Clone ( bound = "" ) ) ]
829
- struct PatStack < ' a , ' p , Cx : TypeCx > {
829
+ struct PatStack < ' p , Cx : TypeCx > {
830
830
// Rows of len 1 are very common, which is why `SmallVec[_; 2]` works well.
831
- pats : SmallVec < [ & ' a DeconstructedPat < ' p , Cx > ; 2 ] > ,
831
+ pats : SmallVec < [ & ' p DeconstructedPat < ' p , Cx > ; 2 ] > ,
832
832
/// Sometimes we know that as far as this row is concerned, the current case is already handled
833
833
/// by a different, more general, case. When the case is irrelevant for all rows this allows us
834
834
/// to skip a case entirely. This is purely an optimization. See at the top for details.
835
835
relevant : bool ,
836
836
}
837
837
838
- impl < ' a , ' p , Cx : TypeCx > PatStack < ' a , ' p , Cx > {
839
- fn from_pattern ( pat : & ' a DeconstructedPat < ' p , Cx > ) -> Self {
838
+ impl < ' a , ' p , Cx : TypeCx > PatStack < ' p , Cx > {
839
+ fn from_pattern ( pat : & ' p DeconstructedPat < ' p , Cx > ) -> Self {
840
840
PatStack { pats : smallvec ! [ pat] , relevant : true }
841
841
}
842
842
@@ -848,17 +848,17 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
848
848
self . pats . len ( )
849
849
}
850
850
851
- fn head ( & self ) -> & ' a DeconstructedPat < ' p , Cx > {
851
+ fn head ( & self ) -> & ' p DeconstructedPat < ' p , Cx > {
852
852
self . pats [ 0 ]
853
853
}
854
854
855
- fn iter < ' b > ( & ' b self ) -> impl Iterator < Item = & ' a DeconstructedPat < ' p , Cx > > + Captures < ' b > {
855
+ fn iter < ' b > ( & ' b self ) -> impl Iterator < Item = & ' p DeconstructedPat < ' p , Cx > > + Captures < ' b > {
856
856
self . pats . iter ( ) . copied ( )
857
857
}
858
858
859
859
// Recursively expand the first or-pattern into its subpatterns. Only useful if the pattern is
860
860
// an or-pattern. Panics if `self` is empty.
861
- fn expand_or_pat < ' b > ( & ' b self ) -> impl Iterator < Item = PatStack < ' a , ' p , Cx > > + Captures < ' b > {
861
+ fn expand_or_pat < ' b > ( & ' b self ) -> impl Iterator < Item = PatStack < ' p , Cx > > + Captures < ' b > {
862
862
self . head ( ) . flatten_or_pat ( ) . into_iter ( ) . map ( move |pat| {
863
863
let mut new = self . clone ( ) ;
864
864
new. pats [ 0 ] = pat;
@@ -873,7 +873,7 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
873
873
pcx : & PlaceCtxt < ' a , ' p , Cx > ,
874
874
ctor : & Constructor < Cx > ,
875
875
ctor_is_relevant : bool ,
876
- ) -> PatStack < ' a , ' p , Cx > {
876
+ ) -> PatStack < ' p , Cx > {
877
877
// We pop the head pattern and push the new fields extracted from the arguments of
878
878
// `self.head()`.
879
879
let mut new_pats = self . head ( ) . specialize ( pcx, ctor) ;
@@ -886,7 +886,7 @@ impl<'a, 'p, Cx: TypeCx> PatStack<'a, 'p, Cx> {
886
886
}
887
887
}
888
888
889
- impl < ' a , ' p , Cx : TypeCx > fmt:: Debug for PatStack < ' a , ' p , Cx > {
889
+ impl < ' p , Cx : TypeCx > fmt:: Debug for PatStack < ' p , Cx > {
890
890
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
891
891
// We pretty-print similarly to the `Debug` impl of `Matrix`.
892
892
write ! ( f, "+" ) ?;
@@ -899,9 +899,9 @@ impl<'a, 'p, Cx: TypeCx> fmt::Debug for PatStack<'a, 'p, Cx> {
899
899
900
900
/// A row of the matrix.
901
901
#[ derive( Clone ) ]
902
- struct MatrixRow < ' a , ' p , Cx : TypeCx > {
902
+ struct MatrixRow < ' p , Cx : TypeCx > {
903
903
// The patterns in the row.
904
- pats : PatStack < ' a , ' p , Cx > ,
904
+ pats : PatStack < ' p , Cx > ,
905
905
/// Whether the original arm had a guard. This is inherited when specializing.
906
906
is_under_guard : bool ,
907
907
/// When we specialize, we remember which row of the original matrix produced a given row of the
@@ -914,7 +914,7 @@ struct MatrixRow<'a, 'p, Cx: TypeCx> {
914
914
useful : bool ,
915
915
}
916
916
917
- impl < ' a , ' p , Cx : TypeCx > MatrixRow < ' a , ' p , Cx > {
917
+ impl < ' a , ' p , Cx : TypeCx > MatrixRow < ' p , Cx > {
918
918
fn is_empty ( & self ) -> bool {
919
919
self . pats . is_empty ( )
920
920
}
@@ -923,17 +923,17 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
923
923
self . pats . len ( )
924
924
}
925
925
926
- fn head ( & self ) -> & ' a DeconstructedPat < ' p , Cx > {
926
+ fn head ( & self ) -> & ' p DeconstructedPat < ' p , Cx > {
927
927
self . pats . head ( )
928
928
}
929
929
930
- fn iter < ' b > ( & ' b self ) -> impl Iterator < Item = & ' a DeconstructedPat < ' p , Cx > > + Captures < ' b > {
930
+ fn iter < ' b > ( & ' b self ) -> impl Iterator < Item = & ' p DeconstructedPat < ' p , Cx > > + Captures < ' b > {
931
931
self . pats . iter ( )
932
932
}
933
933
934
934
// Recursively expand the first or-pattern into its subpatterns. Only useful if the pattern is
935
935
// an or-pattern. Panics if `self` is empty.
936
- fn expand_or_pat < ' b > ( & ' b self ) -> impl Iterator < Item = MatrixRow < ' a , ' p , Cx > > + Captures < ' b > {
936
+ fn expand_or_pat < ' b > ( & ' b self ) -> impl Iterator < Item = MatrixRow < ' p , Cx > > + Captures < ' b > {
937
937
self . pats . expand_or_pat ( ) . map ( |patstack| MatrixRow {
938
938
pats : patstack,
939
939
parent_row : self . parent_row ,
@@ -950,7 +950,7 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
950
950
ctor : & Constructor < Cx > ,
951
951
ctor_is_relevant : bool ,
952
952
parent_row : usize ,
953
- ) -> MatrixRow < ' a , ' p , Cx > {
953
+ ) -> MatrixRow < ' p , Cx > {
954
954
MatrixRow {
955
955
pats : self . pats . pop_head_constructor ( pcx, ctor, ctor_is_relevant) ,
956
956
parent_row,
@@ -960,7 +960,7 @@ impl<'a, 'p, Cx: TypeCx> MatrixRow<'a, 'p, Cx> {
960
960
}
961
961
}
962
962
963
- impl < ' a , ' p , Cx : TypeCx > fmt:: Debug for MatrixRow < ' a , ' p , Cx > {
963
+ impl < ' p , Cx : TypeCx > fmt:: Debug for MatrixRow < ' p , Cx > {
964
964
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
965
965
self . pats . fmt ( f)
966
966
}
@@ -977,22 +977,22 @@ impl<'a, 'p, Cx: TypeCx> fmt::Debug for MatrixRow<'a, 'p, Cx> {
977
977
/// specializing `(,)` and `Some` on a pattern of type `(Option<u32>, bool)`, the first column of
978
978
/// the matrix will correspond to `scrutinee.0.Some.0` and the second column to `scrutinee.1`.
979
979
#[ derive( Clone ) ]
980
- struct Matrix < ' a , ' p , Cx : TypeCx > {
980
+ struct Matrix < ' p , Cx : TypeCx > {
981
981
/// Vector of rows. The rows must form a rectangular 2D array. Moreover, all the patterns of
982
982
/// each column must have the same type. Each column corresponds to a place within the
983
983
/// scrutinee.
984
- rows : Vec < MatrixRow < ' a , ' p , Cx > > ,
984
+ rows : Vec < MatrixRow < ' p , Cx > > ,
985
985
/// Stores an extra fictitious row full of wildcards. Mostly used to keep track of the type of
986
986
/// each column. This must obey the same invariants as the real rows.
987
- wildcard_row : PatStack < ' a , ' p , Cx > ,
987
+ wildcard_row : PatStack < ' p , Cx > ,
988
988
/// Track for each column/place whether it contains a known valid value.
989
989
place_validity : SmallVec < [ ValidityConstraint ; 2 ] > ,
990
990
}
991
991
992
- impl < ' a , ' p , Cx : TypeCx > Matrix < ' a , ' p , Cx > {
992
+ impl < ' a , ' p , Cx : TypeCx > Matrix < ' p , Cx > {
993
993
/// Pushes a new row to the matrix. If the row starts with an or-pattern, this recursively
994
994
/// expands it. Internal method, prefer [`Matrix::new`].
995
- fn expand_and_push ( & mut self , row : MatrixRow < ' a , ' p , Cx > ) {
995
+ fn expand_and_push ( & mut self , row : MatrixRow < ' p , Cx > ) {
996
996
if !row. is_empty ( ) && row. head ( ) . is_or_pat ( ) {
997
997
// Expand nested or-patterns.
998
998
for new_row in row. expand_or_pat ( ) {
@@ -1005,7 +1005,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
1005
1005
1006
1006
/// Build a new matrix from an iterator of `MatchArm`s.
1007
1007
fn new (
1008
- wildcard_arena : & ' a TypedArena < DeconstructedPat < ' p , Cx > > ,
1008
+ wildcard_arena : & ' p TypedArena < DeconstructedPat < ' p , Cx > > ,
1009
1009
arms : & ' a [ MatchArm < ' p , Cx > ] ,
1010
1010
scrut_ty : Cx :: Ty ,
1011
1011
scrut_validity : ValidityConstraint ,
@@ -1044,13 +1044,13 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
1044
1044
1045
1045
fn rows < ' b > (
1046
1046
& ' b self ,
1047
- ) -> impl Iterator < Item = & ' b MatrixRow < ' a , ' p , Cx > > + Clone + DoubleEndedIterator + ExactSizeIterator
1047
+ ) -> impl Iterator < Item = & ' b MatrixRow < ' p , Cx > > + Clone + DoubleEndedIterator + ExactSizeIterator
1048
1048
{
1049
1049
self . rows . iter ( )
1050
1050
}
1051
1051
fn rows_mut < ' b > (
1052
1052
& ' b mut self ,
1053
- ) -> impl Iterator < Item = & ' b mut MatrixRow < ' a , ' p , Cx > > + DoubleEndedIterator + ExactSizeIterator
1053
+ ) -> impl Iterator < Item = & ' b mut MatrixRow < ' p , Cx > > + DoubleEndedIterator + ExactSizeIterator
1054
1054
{
1055
1055
self . rows . iter_mut ( )
1056
1056
}
@@ -1068,7 +1068,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
1068
1068
pcx : & PlaceCtxt < ' a , ' p , Cx > ,
1069
1069
ctor : & Constructor < Cx > ,
1070
1070
ctor_is_relevant : bool ,
1071
- ) -> Matrix < ' a , ' p , Cx > {
1071
+ ) -> Matrix < ' p , Cx > {
1072
1072
let wildcard_row = self . wildcard_row . pop_head_constructor ( pcx, ctor, ctor_is_relevant) ;
1073
1073
let new_validity = self . place_validity [ 0 ] . specialize ( ctor) ;
1074
1074
let new_place_validity = std:: iter:: repeat ( new_validity)
@@ -1097,7 +1097,7 @@ impl<'a, 'p, Cx: TypeCx> Matrix<'a, 'p, Cx> {
1097
1097
/// + _ + [_, _, tail @ ..] +
1098
1098
/// | ✓ | ? | // column validity
1099
1099
/// ```
1100
- impl < ' a , ' p , Cx : TypeCx > fmt:: Debug for Matrix < ' a , ' p , Cx > {
1100
+ impl < ' p , Cx : TypeCx > fmt:: Debug for Matrix < ' p , Cx > {
1101
1101
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1102
1102
write ! ( f, "\n " ) ?;
1103
1103
@@ -1336,7 +1336,7 @@ impl<Cx: TypeCx> WitnessMatrix<Cx> {
1336
1336
#[ instrument( level = "debug" , skip( mcx, is_top_level) , ret) ]
1337
1337
fn compute_exhaustiveness_and_usefulness < ' a , ' p , Cx : TypeCx > (
1338
1338
mcx : MatchCtxt < ' a , ' p , Cx > ,
1339
- matrix : & mut Matrix < ' a , ' p , Cx > ,
1339
+ matrix : & mut Matrix < ' p , Cx > ,
1340
1340
is_top_level : bool ,
1341
1341
) -> WitnessMatrix < Cx > {
1342
1342
debug_assert ! ( matrix. rows( ) . all( |r| r. len( ) == matrix. column_count( ) ) ) ;
0 commit comments