@@ -48,32 +48,29 @@ pub enum Component<'tcx> {
48
48
impl < ' tcx > TyCtxt < ' tcx > {
49
49
/// Push onto `out` all the things that must outlive `'a` for the condition
50
50
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
51
- pub fn push_outlives_components (
52
- & self ,
53
- ty0 : Ty < ' tcx > ,
54
- out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ,
55
- ) {
56
- self . compute_components ( ty0, out) ;
51
+ pub fn push_outlives_components ( self , ty0 : Ty < ' tcx > , out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ) {
52
+ compute_components ( self , ty0, out) ;
57
53
debug ! ( "components({:?}) = {:?}" , ty0, out) ;
58
54
}
55
+ }
59
56
60
- fn compute_components ( & self , ty : Ty < ' tcx > , out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ) {
61
- // Descend through the types, looking for the various "base"
62
- // components and collecting them into `out`. This is not written
63
- // with `collect()` because of the need to sometimes skip subtrees
64
- // in the `subtys` iterator (e.g., when encountering a
65
- // projection).
66
- match ty. kind {
57
+ fn compute_components ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ) {
58
+ // Descend through the types, looking for the various "base"
59
+ // components and collecting them into `out`. This is not written
60
+ // with `collect()` because of the need to sometimes skip subtrees
61
+ // in the `subtys` iterator (e.g., when encountering a
62
+ // projection).
63
+ match ty. kind {
67
64
ty:: Closure ( def_id, ref substs) => {
68
- for upvar_ty in substs. as_closure ( ) . upvar_tys ( def_id, * self ) {
69
- self . compute_components ( upvar_ty, out) ;
65
+ for upvar_ty in substs. as_closure ( ) . upvar_tys ( def_id, tcx ) {
66
+ compute_components ( tcx , upvar_ty, out) ;
70
67
}
71
68
}
72
69
73
70
ty:: Generator ( def_id, ref substs, _) => {
74
71
// Same as the closure case
75
- for upvar_ty in substs. as_generator ( ) . upvar_tys ( def_id, * self ) {
76
- self . compute_components ( upvar_ty, out) ;
72
+ for upvar_ty in substs. as_generator ( ) . upvar_tys ( def_id, tcx ) {
73
+ compute_components ( tcx , upvar_ty, out) ;
77
74
}
78
75
79
76
// We ignore regions in the generator interior as we don't
@@ -110,7 +107,7 @@ impl<'tcx> TyCtxt<'tcx> {
110
107
// fallback case: hard code
111
108
// OutlivesProjectionComponents. Continue walking
112
109
// through and constrain Pi.
113
- let subcomponents = self . capture_components ( ty) ;
110
+ let subcomponents = capture_components ( tcx , ty) ;
114
111
out. push ( Component :: EscapingProjection ( subcomponents) ) ;
115
112
}
116
113
}
@@ -159,20 +156,19 @@ impl<'tcx> TyCtxt<'tcx> {
159
156
160
157
push_region_constraints ( ty, out) ;
161
158
for subty in ty. walk_shallow ( ) {
162
- self . compute_components ( subty, out) ;
159
+ compute_components ( tcx , subty, out) ;
163
160
}
164
161
}
165
162
}
166
- }
163
+ }
167
164
168
- fn capture_components ( & self , ty : Ty < ' tcx > ) -> Vec < Component < ' tcx > > {
169
- let mut temp = smallvec ! [ ] ;
170
- push_region_constraints ( ty, & mut temp) ;
171
- for subty in ty. walk_shallow ( ) {
172
- self . compute_components ( subty, & mut temp) ;
173
- }
174
- temp. into_iter ( ) . collect ( )
165
+ fn capture_components ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> Vec < Component < ' tcx > > {
166
+ let mut temp = smallvec ! [ ] ;
167
+ push_region_constraints ( ty, & mut temp) ;
168
+ for subty in ty. walk_shallow ( ) {
169
+ compute_components ( tcx, subty, & mut temp) ;
175
170
}
171
+ temp. into_iter ( ) . collect ( )
176
172
}
177
173
178
174
fn push_region_constraints < ' tcx > ( ty : Ty < ' tcx > , out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ) {
0 commit comments