@@ -287,6 +287,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
287
287
found_it : false ,
288
288
bound_region : self . bound_region ,
289
289
hir_map : self . hir_map ,
290
+ depth : self . depth ,
290
291
} ;
291
292
intravisit:: walk_ty ( subvisitor, arg) ; // call walk_ty; as visit_ty is empty,
292
293
// this will visit only outermost type
@@ -313,6 +314,7 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
313
314
hir_map : & ' a hir:: map:: Map < ' gcx > ,
314
315
found_it : bool ,
315
316
bound_region : ty:: BoundRegion ,
317
+ depth : u32 ,
316
318
}
317
319
318
320
impl < ' a , ' gcx , ' tcx > Visitor < ' gcx > for TyPathVisitor < ' a , ' gcx , ' tcx > {
@@ -326,7 +328,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
326
328
match ( self . infcx . tcx . named_region ( hir_id) , self . bound_region ) {
327
329
// the lifetime of the TyPath!
328
330
( Some ( rl:: Region :: LateBoundAnon ( debruijn_index, anon_index) ) , ty:: BrAnon ( br_index) ) => {
329
- if debruijn_index. depth == 1 && anon_index == br_index {
331
+ if debruijn_index. depth == self . depth && anon_index == br_index {
330
332
self . found_it = true ;
331
333
return ;
332
334
}
@@ -349,7 +351,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
349
351
debug ! ( "self.infcx.tcx.hir.local_def_id(id)={:?}" ,
350
352
self . infcx. tcx. hir. local_def_id( id) ) ;
351
353
debug ! ( "def_id={:?}" , def_id) ;
352
- if debruijn_index. depth == 1 && self . infcx . tcx . hir . local_def_id ( id) == def_id {
354
+ if debruijn_index. depth == self . depth &&
355
+ self . infcx . tcx . hir . local_def_id ( id) == def_id {
353
356
self . found_it = true ;
354
357
return ; // we can stop visiting now
355
358
}
0 commit comments