@@ -689,7 +689,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
689
689
-> Option < Span > {
690
690
struct LateBoundRegionsDetector < ' a , ' tcx : ' a > {
691
691
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
692
- binder_depth : u32 ,
692
+ outer_index : ty :: DebruijnIndex ,
693
693
has_late_bound_regions : Option < Span > ,
694
694
}
695
695
@@ -702,9 +702,9 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
702
702
if self . has_late_bound_regions . is_some ( ) { return }
703
703
match ty. node {
704
704
hir:: TyBareFn ( ..) => {
705
- self . binder_depth += 1 ;
705
+ self . outer_index . shift_in ( 1 ) ;
706
706
intravisit:: walk_ty ( self , ty) ;
707
- self . binder_depth -= 1 ;
707
+ self . outer_index . shift_out ( 1 ) ;
708
708
}
709
709
_ => intravisit:: walk_ty ( self , ty)
710
710
}
@@ -714,9 +714,9 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
714
714
tr : & ' tcx hir:: PolyTraitRef ,
715
715
m : hir:: TraitBoundModifier ) {
716
716
if self . has_late_bound_regions . is_some ( ) { return }
717
- self . binder_depth += 1 ;
717
+ self . outer_index . shift_in ( 1 ) ;
718
718
intravisit:: walk_poly_trait_ref ( self , tr, m) ;
719
- self . binder_depth -= 1 ;
719
+ self . outer_index . shift_out ( 1 ) ;
720
720
}
721
721
722
722
fn visit_lifetime ( & mut self , lt : & ' tcx hir:: Lifetime ) {
@@ -727,8 +727,13 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
727
727
Some ( rl:: Region :: Static ) | Some ( rl:: Region :: EarlyBound ( ..) ) => { }
728
728
Some ( rl:: Region :: LateBound ( debruijn, _, _) ) |
729
729
Some ( rl:: Region :: LateBoundAnon ( debruijn, _) )
730
- if debruijn. depth < self . binder_depth => { }
731
- _ => self . has_late_bound_regions = Some ( lt. span ) ,
730
+ if debruijn < self . outer_index => { }
731
+ Some ( rl:: Region :: LateBound ( ..) ) |
732
+ Some ( rl:: Region :: LateBoundAnon ( ..) ) |
733
+ Some ( rl:: Region :: Free ( ..) ) |
734
+ None => {
735
+ self . has_late_bound_regions = Some ( lt. span ) ;
736
+ }
732
737
}
733
738
}
734
739
}
@@ -738,7 +743,9 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
738
743
decl : & ' tcx hir:: FnDecl )
739
744
-> Option < Span > {
740
745
let mut visitor = LateBoundRegionsDetector {
741
- tcx, binder_depth : 1 , has_late_bound_regions : None
746
+ tcx,
747
+ outer_index : ty:: DebruijnIndex :: INNERMOST ,
748
+ has_late_bound_regions : None ,
742
749
} ;
743
750
for lifetime in generics. lifetimes ( ) {
744
751
let hir_id = tcx. hir . node_to_hir_id ( lifetime. lifetime . id ) ;
0 commit comments