@@ -62,6 +62,27 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
6262 // in the `subtys` iterator (e.g., when encountering a
6363 // projection).
6464 match ty. kind {
65+ ty:: FnDef ( _, substs) => {
66+ // HACK(eddyb) ignore lifetimes found shallowly in `substs`.
67+ // This is inconsistent with `ty::Adt` (including all substs)
68+ // and with `ty::Closure` (ignoring all substs other than
69+ // upvars, of which a `ty::FnDef` doesn't have any), but
70+ // consistent with previous (accidental) behavior.
71+ // See https://github.com/rust-lang/rust/issues/70917
72+ // for further background and discussion.
73+ for & child in substs {
74+ match child. unpack ( ) {
75+ GenericArgKind :: Type ( ty) => {
76+ compute_components ( tcx, ty, out) ;
77+ }
78+ GenericArgKind :: Lifetime ( _) => { }
79+ GenericArgKind :: Const ( _) => {
80+ compute_components_recursive ( tcx, child, out) ;
81+ }
82+ }
83+ }
84+ }
85+
6586 ty:: Closure ( _, ref substs) => {
6687 for upvar_ty in substs. as_closure ( ) . upvar_tys ( ) {
6788 compute_components ( tcx, upvar_ty, out) ;
@@ -136,23 +157,22 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
136157 ty:: Float ( ..) | // OutlivesScalar
137158 ty:: Never | // ...
138159 ty:: Adt ( ..) | // OutlivesNominalType
139- ty:: Opaque ( ..) | // OutlivesNominalType (ish)
160+ ty:: Opaque ( ..) | // OutlivesNominalType (ish)
140161 ty:: Foreign ( ..) | // OutlivesNominalType
141162 ty:: Str | // OutlivesScalar (ish)
142163 ty:: Array ( ..) | // ...
143164 ty:: Slice ( ..) | // ...
144165 ty:: RawPtr ( ..) | // ...
145166 ty:: Ref ( ..) | // OutlivesReference
146167 ty:: Tuple ( ..) | // ...
147- ty:: FnDef ( ..) | // OutlivesFunction (*)
148168 ty:: FnPtr ( _) | // OutlivesFunction (*)
149- ty:: Dynamic ( ..) | // OutlivesObject, OutlivesFragment (*)
169+ ty:: Dynamic ( ..) | // OutlivesObject, OutlivesFragment (*)
150170 ty:: Placeholder ( ..) |
151171 ty:: Bound ( ..) |
152172 ty:: Error => {
153- // (*) Bare functions and traits are both binders. In the
154- // RFC, this means we would add the bound regions to the
155- // "bound regions list". In our representation, no such
173+ // (*) Function pointers and trait objects are both binders.
174+ // In the RFC, this means we would add the bound regions to
175+ // the "bound regions list". In our representation, no such
156176 // list is maintained explicitly, because bound regions
157177 // themselves can be readily identified.
158178 compute_components_recursive ( tcx, ty. into ( ) , out) ;
0 commit comments