@@ -287,6 +287,7 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for FindNestedTypeVisitor<'a, 'gcx, 'tcx> {
287287 found_it : false ,
288288 bound_region : self . bound_region ,
289289 hir_map : self . hir_map ,
290+ depth : self . depth ,
290291 } ;
291292 intravisit:: walk_ty ( subvisitor, arg) ; // call walk_ty; as visit_ty is empty,
292293 // this will visit only outermost type
@@ -313,6 +314,7 @@ struct TyPathVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
313314 hir_map : & ' a hir:: map:: Map < ' gcx > ,
314315 found_it : bool ,
315316 bound_region : ty:: BoundRegion ,
317+ depth : u32 ,
316318}
317319
318320impl < ' 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> {
326328 match ( self . infcx . tcx . named_region ( hir_id) , self . bound_region ) {
327329 // the lifetime of the TyPath!
328330 ( 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 {
330332 self . found_it = true ;
331333 return ;
332334 }
@@ -349,7 +351,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
349351 debug ! ( "self.infcx.tcx.hir.local_def_id(id)={:?}" ,
350352 self . infcx. tcx. hir. local_def_id( id) ) ;
351353 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 {
353356 self . found_it = true ;
354357 return ; // we can stop visiting now
355358 }
0 commit comments