@@ -62,6 +62,27 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
62
62
// in the `subtys` iterator (e.g., when encountering a
63
63
// projection).
64
64
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
+
65
86
ty:: Closure ( _, ref substs) => {
66
87
for upvar_ty in substs. as_closure ( ) . upvar_tys ( ) {
67
88
compute_components ( tcx, upvar_ty, out) ;
@@ -136,23 +157,22 @@ fn compute_components(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, out: &mut SmallVec<[Compo
136
157
ty:: Float ( ..) | // OutlivesScalar
137
158
ty:: Never | // ...
138
159
ty:: Adt ( ..) | // OutlivesNominalType
139
- ty:: Opaque ( ..) | // OutlivesNominalType (ish)
160
+ ty:: Opaque ( ..) | // OutlivesNominalType (ish)
140
161
ty:: Foreign ( ..) | // OutlivesNominalType
141
162
ty:: Str | // OutlivesScalar (ish)
142
163
ty:: Array ( ..) | // ...
143
164
ty:: Slice ( ..) | // ...
144
165
ty:: RawPtr ( ..) | // ...
145
166
ty:: Ref ( ..) | // OutlivesReference
146
167
ty:: Tuple ( ..) | // ...
147
- ty:: FnDef ( ..) | // OutlivesFunction (*)
148
168
ty:: FnPtr ( _) | // OutlivesFunction (*)
149
- ty:: Dynamic ( ..) | // OutlivesObject, OutlivesFragment (*)
169
+ ty:: Dynamic ( ..) | // OutlivesObject, OutlivesFragment (*)
150
170
ty:: Placeholder ( ..) |
151
171
ty:: Bound ( ..) |
152
172
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
156
176
// list is maintained explicitly, because bound regions
157
177
// themselves can be readily identified.
158
178
compute_components_recursive ( tcx, ty. into ( ) , out) ;
0 commit comments