@@ -143,7 +143,7 @@ fn compute_components<'tcx>(
143143 // through and constrain Pi.
144144 let mut subcomponents = smallvec ! [ ] ;
145145 let mut subvisited = SsoHashSet :: new ( ) ;
146- compute_components_recursive ( tcx, ty. into ( ) , & mut subcomponents, & mut subvisited) ;
146+ compute_alias_components_recursive ( tcx, ty, & mut subcomponents, & mut subvisited) ;
147147 out. push ( Component :: EscapingAlias ( subcomponents. into_iter ( ) . collect ( ) ) ) ;
148148 }
149149 }
@@ -193,7 +193,43 @@ fn compute_components<'tcx>(
193193///
194194/// This should not be used to get the components of `parent` itself.
195195/// Use [push_outlives_components] instead.
196- pub ( super ) fn compute_components_recursive < ' tcx > (
196+ pub ( super ) fn compute_alias_components_recursive < ' tcx > (
197+ tcx : TyCtxt < ' tcx > ,
198+ alias_ty : Ty < ' tcx > ,
199+ out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ,
200+ visited : & mut SsoHashSet < GenericArg < ' tcx > > ,
201+ ) {
202+ let ty:: Alias ( kind, alias_ty) = alias_ty. kind ( ) else { bug ! ( ) } ;
203+ let opt_variances = if * kind == ty:: Opaque { tcx. variances_of ( alias_ty. def_id ) } else { & [ ] } ;
204+ for ( index, child) in alias_ty. substs . iter ( ) . enumerate ( ) {
205+ if opt_variances. get ( index) == Some ( & ty:: Bivariant ) {
206+ continue ;
207+ }
208+ if !visited. insert ( child) {
209+ continue ;
210+ }
211+ match child. unpack ( ) {
212+ GenericArgKind :: Type ( ty) => {
213+ compute_components ( tcx, ty, out, visited) ;
214+ }
215+ GenericArgKind :: Lifetime ( lt) => {
216+ // Ignore late-bound regions.
217+ if !lt. is_late_bound ( ) {
218+ out. push ( Component :: Region ( lt) ) ;
219+ }
220+ }
221+ GenericArgKind :: Const ( _) => {
222+ compute_components_recursive ( tcx, child, out, visited) ;
223+ }
224+ }
225+ }
226+ }
227+
228+ /// Collect [Component]s for *all* the substs of `parent`.
229+ ///
230+ /// This should not be used to get the components of `parent` itself.
231+ /// Use [push_outlives_components] instead.
232+ fn compute_components_recursive < ' tcx > (
197233 tcx : TyCtxt < ' tcx > ,
198234 parent : GenericArg < ' tcx > ,
199235 out : & mut SmallVec < [ Component < ' tcx > ; 4 ] > ,
0 commit comments