@@ -48,32 +48,29 @@ pub enum Component<'tcx> {
4848impl < ' tcx > TyCtxt < ' tcx > {
4949 /// Push onto `out` all the things that must outlive `'a` for the condition
5050 /// `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) ;
5753 debug ! ( "components({:?}) = {:?}" , ty0, out) ;
5854 }
55+ }
5956
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 {
6764 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) ;
7067 }
7168 }
7269
7370 ty:: Generator ( def_id, ref substs, _) => {
7471 // 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) ;
7774 }
7875
7976 // We ignore regions in the generator interior as we don't
@@ -110,7 +107,7 @@ impl<'tcx> TyCtxt<'tcx> {
110107 // fallback case: hard code
111108 // OutlivesProjectionComponents. Continue walking
112109 // through and constrain Pi.
113- let subcomponents = self . capture_components ( ty) ;
110+ let subcomponents = capture_components ( tcx , ty) ;
114111 out. push ( Component :: EscapingProjection ( subcomponents) ) ;
115112 }
116113 }
@@ -159,20 +156,19 @@ impl<'tcx> TyCtxt<'tcx> {
159156
160157 push_region_constraints ( ty, out) ;
161158 for subty in ty. walk_shallow ( ) {
162- self . compute_components ( subty, out) ;
159+ compute_components ( tcx , subty, out) ;
163160 }
164161 }
165162 }
166- }
163+ }
167164
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) ;
175170 }
171+ temp. into_iter ( ) . collect ( )
176172}
177173
178174fn push_region_constraints < ' tcx > ( ty : Ty < ' tcx > , out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ) {
0 commit comments