@@ -321,24 +321,46 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
321
321
}
322
322
323
323
fn visit_lifetime ( & mut self , lifetime : & hir:: Lifetime ) {
324
- let br_index = match self . bound_region {
325
- ty:: BrAnon ( index) => index,
326
- _ => return ,
327
- } ;
328
324
329
325
let hir_id = self . infcx . tcx . hir . node_to_hir_id ( lifetime. id ) ;
330
- match self . infcx . tcx . named_region ( hir_id) {
326
+ match ( self . infcx . tcx . named_region ( hir_id) , self . bound_region ) {
331
327
// the lifetime of the TyPath!
332
- Some ( rl:: Region :: LateBoundAnon ( debruijn_index, anon_index) ) => {
328
+ ( Some ( rl:: Region :: LateBoundAnon ( debruijn_index, anon_index) ) , ty :: BrAnon ( br_index ) ) => {
333
329
if debruijn_index. depth == 1 && anon_index == br_index {
334
330
self . found_it = true ;
331
+ return ;
332
+ }
333
+ }
334
+
335
+ ( Some ( rl:: Region :: EarlyBound ( _, id) ) , ty:: BrNamed ( def_id, _) ) => {
336
+ debug ! ( "EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
337
+ def_id={:?}",
338
+ self . infcx. tcx. hir. local_def_id( id) ,
339
+ def_id) ;
340
+ if self . infcx . tcx . hir . local_def_id ( id) == def_id {
341
+ self . found_it = true ;
342
+ return ; // we can stop visiting now
335
343
}
336
344
}
337
- Some ( rl:: Region :: Static ) |
338
- Some ( rl:: Region :: EarlyBound ( _, _) ) |
339
- Some ( rl:: Region :: LateBound ( _, _) ) |
340
- Some ( rl:: Region :: Free ( _, _) ) |
341
- None => {
345
+
346
+ ( Some ( rl:: Region :: LateBound ( debruijn_index, id) ) , ty:: BrNamed ( def_id, _) ) => {
347
+ debug ! ( "FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}" ,
348
+ debruijn_index. depth) ;
349
+ debug ! ( "self.infcx.tcx.hir.local_def_id(id)={:?}" ,
350
+ self . infcx. tcx. hir. local_def_id( id) ) ;
351
+ debug ! ( "def_id={:?}" , def_id) ;
352
+ if debruijn_index. depth == 1 && self . infcx . tcx . hir . local_def_id ( id) == def_id {
353
+ self . found_it = true ;
354
+ return ; // we can stop visiting now
355
+ }
356
+ }
357
+
358
+ ( Some ( rl:: Region :: Static ) , _) |
359
+ ( Some ( rl:: Region :: EarlyBound ( _, _) ) , _) |
360
+ ( Some ( rl:: Region :: LateBound ( _, _) ) , _) |
361
+ ( Some ( rl:: Region :: LateBoundAnon ( _, _) ) , _) |
362
+ ( Some ( rl:: Region :: Free ( _, _) ) , _) |
363
+ ( None , _) => {
342
364
debug ! ( "no arg found" ) ;
343
365
}
344
366
}
0 commit comments