@@ -173,6 +173,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
173
173
hir_map : & self . tcx . hir ,
174
174
bound_region : * br,
175
175
found_type : None ,
176
+ depth : 1 ,
176
177
} ;
177
178
nested_visitor. visit_ty ( arg) ;
178
179
nested_visitor. found_type
@@ -195,6 +196,7 @@ struct FindNestedTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
195
196
// The type where the anonymous lifetime appears
196
197
// for e.g. Vec<`&u8`> and <`&u8`>
197
198
found_type : Option < & ' gcx hir:: Ty > ,
199
+ depth : u32 ,
198
200
}
199
201
200
202
impl < ' a , ' gcx , ' tcx > Visitor < ' gcx > for FindNestedTypeVisitor < ' a , ' gcx , ' tcx > {
@@ -211,6 +213,14 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
211
213
return ;
212
214
}
213
215
216
+ hir:: TyTraitObject ( ref bounds, _) => {
217
+ for bound in bounds {
218
+ self . depth += 1 ;
219
+ self . visit_poly_trait_ref ( bound, hir:: TraitBoundModifier :: None ) ;
220
+ self . depth -= 1 ;
221
+ }
222
+ }
223
+
214
224
hir:: TyRptr ( ref lifetime, _) => {
215
225
// the lifetime of the TyRptr
216
226
let hir_id = self . infcx . tcx . hir . node_to_hir_id ( lifetime. id ) ;
@@ -224,7 +234,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
224
234
debruijn_index. depth,
225
235
anon_index,
226
236
br_index) ;
227
- if debruijn_index. depth == 1 && anon_index == br_index {
237
+ if debruijn_index. depth == self . depth && anon_index == br_index {
228
238
self . found_type = Some ( arg) ;
229
239
return ; // we can stop visiting now
230
240
}
@@ -253,7 +263,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
253
263
debug ! ( "self.infcx.tcx.hir.local_def_id(id)={:?}" ,
254
264
self . infcx. tcx. hir. local_def_id( id) ) ;
255
265
debug ! ( "def_id={:?}" , def_id) ;
256
- if debruijn_index. depth == 1 &&
266
+ if debruijn_index. depth == self . depth &&
257
267
self . infcx . tcx . hir . local_def_id ( id) == def_id {
258
268
self . found_type = Some ( arg) ;
259
269
return ; // we can stop visiting now
0 commit comments