1+ use std:: sync:: Arc ;
2+
13use rustc_middle:: mir:: * ;
24use rustc_middle:: thir:: { self , * } ;
35use rustc_middle:: ty:: { self , Ty , TypeVisitableExt } ;
@@ -12,11 +14,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1214 /// [`PatKind::Leaf`].
1315 ///
1416 /// Used internally by [`MatchPairTree::for_pattern`].
15- fn field_match_pairs < ' pat > (
17+ fn field_match_pairs (
1618 & mut self ,
1719 place : PlaceBuilder < ' tcx > ,
18- subpatterns : & ' pat [ FieldPat < ' tcx > ] ,
19- ) -> Vec < MatchPairTree < ' pat , ' tcx > > {
20+ subpatterns : & [ FieldPat < ' tcx > ] ,
21+ ) -> Vec < MatchPairTree < ' tcx > > {
2022 subpatterns
2123 . iter ( )
2224 . map ( |fieldpat| {
@@ -31,13 +33,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3133 /// array pattern or slice pattern, and adds those trees to `match_pairs`.
3234 ///
3335 /// Used internally by [`MatchPairTree::for_pattern`].
34- fn prefix_slice_suffix < ' pat > (
36+ fn prefix_slice_suffix (
3537 & mut self ,
36- match_pairs : & mut Vec < MatchPairTree < ' pat , ' tcx > > ,
38+ match_pairs : & mut Vec < MatchPairTree < ' tcx > > ,
3739 place : & PlaceBuilder < ' tcx > ,
38- prefix : & ' pat [ Box < Pat < ' tcx > > ] ,
39- opt_slice : & ' pat Option < Box < Pat < ' tcx > > > ,
40- suffix : & ' pat [ Box < Pat < ' tcx > > ] ,
40+ prefix : & [ Box < Pat < ' tcx > > ] ,
41+ opt_slice : & Option < Box < Pat < ' tcx > > > ,
42+ suffix : & [ Box < Pat < ' tcx > > ] ,
4143 ) {
4244 let tcx = self . tcx ;
4345 let ( min_length, exact_size) = if let Some ( place_resolved) = place. try_to_place ( self ) {
@@ -83,14 +85,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8385 }
8486}
8587
86- impl < ' pat , ' tcx > MatchPairTree < ' pat , ' tcx > {
88+ impl < ' tcx > MatchPairTree < ' tcx > {
8789 /// Recursively builds a match pair tree for the given pattern and its
8890 /// subpatterns.
8991 pub ( in crate :: builder) fn for_pattern (
9092 mut place_builder : PlaceBuilder < ' tcx > ,
91- pattern : & ' pat Pat < ' tcx > ,
93+ pattern : & Pat < ' tcx > ,
9294 cx : & mut Builder < ' _ , ' tcx > ,
93- ) -> MatchPairTree < ' pat , ' tcx > {
95+ ) -> MatchPairTree < ' tcx > {
9496 // Force the place type to the pattern's type.
9597 // FIXME(oli-obk): can we use this to simplify slice/array pattern hacks?
9698 if let Some ( resolved) = place_builder. resolve_upvar ( cx) {
@@ -125,7 +127,7 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
125127 if range. is_full_range ( cx. tcx ) == Some ( true ) {
126128 default_irrefutable ( )
127129 } else {
128- TestCase :: Range ( range)
130+ TestCase :: Range ( Arc :: clone ( range) )
129131 }
130132 }
131133
@@ -255,6 +257,12 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
255257 PatKind :: Never => TestCase :: Never ,
256258 } ;
257259
258- MatchPairTree { place, test_case, subpairs, pattern }
260+ MatchPairTree {
261+ place,
262+ test_case,
263+ subpairs,
264+ pattern_ty : pattern. ty ,
265+ pattern_span : pattern. span ,
266+ }
259267 }
260268}
0 commit comments