1
+ use std:: sync:: Arc ;
2
+
1
3
use rustc_middle:: mir:: * ;
2
4
use rustc_middle:: thir:: { self , * } ;
3
5
use rustc_middle:: ty:: { self , Ty , TypeVisitableExt } ;
@@ -12,11 +14,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
12
14
/// [`PatKind::Leaf`].
13
15
///
14
16
/// Used internally by [`MatchPairTree::for_pattern`].
15
- fn field_match_pairs < ' pat > (
17
+ fn field_match_pairs (
16
18
& mut self ,
17
19
place : PlaceBuilder < ' tcx > ,
18
- subpatterns : & ' pat [ FieldPat < ' tcx > ] ,
19
- ) -> Vec < MatchPairTree < ' pat , ' tcx > > {
20
+ subpatterns : & [ FieldPat < ' tcx > ] ,
21
+ ) -> Vec < MatchPairTree < ' tcx > > {
20
22
subpatterns
21
23
. iter ( )
22
24
. map ( |fieldpat| {
@@ -31,13 +33,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
31
33
/// array pattern or slice pattern, and adds those trees to `match_pairs`.
32
34
///
33
35
/// Used internally by [`MatchPairTree::for_pattern`].
34
- fn prefix_slice_suffix < ' pat > (
36
+ fn prefix_slice_suffix (
35
37
& mut self ,
36
- match_pairs : & mut Vec < MatchPairTree < ' pat , ' tcx > > ,
38
+ match_pairs : & mut Vec < MatchPairTree < ' tcx > > ,
37
39
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 > > ] ,
41
43
) {
42
44
let tcx = self . tcx ;
43
45
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> {
83
85
}
84
86
}
85
87
86
- impl < ' pat , ' tcx > MatchPairTree < ' pat , ' tcx > {
88
+ impl < ' tcx > MatchPairTree < ' tcx > {
87
89
/// Recursively builds a match pair tree for the given pattern and its
88
90
/// subpatterns.
89
91
pub ( in crate :: builder) fn for_pattern (
90
92
mut place_builder : PlaceBuilder < ' tcx > ,
91
- pattern : & ' pat Pat < ' tcx > ,
93
+ pattern : & Pat < ' tcx > ,
92
94
cx : & mut Builder < ' _ , ' tcx > ,
93
- ) -> MatchPairTree < ' pat , ' tcx > {
95
+ ) -> MatchPairTree < ' tcx > {
94
96
// Force the place type to the pattern's type.
95
97
// FIXME(oli-obk): can we use this to simplify slice/array pattern hacks?
96
98
if let Some ( resolved) = place_builder. resolve_upvar ( cx) {
@@ -125,7 +127,7 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
125
127
if range. is_full_range ( cx. tcx ) == Some ( true ) {
126
128
default_irrefutable ( )
127
129
} else {
128
- TestCase :: Range ( range)
130
+ TestCase :: Range ( Arc :: clone ( range) )
129
131
}
130
132
}
131
133
@@ -255,6 +257,12 @@ impl<'pat, 'tcx> MatchPairTree<'pat, 'tcx> {
255
257
PatKind :: Never => TestCase :: Never ,
256
258
} ;
257
259
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
+ }
259
267
}
260
268
}
0 commit comments