@@ -774,11 +774,11 @@ fn trait_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
774
774
775
775
fn has_late_bound_regions < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
776
776
node : hir_map:: Node < ' tcx > )
777
- -> bool {
777
+ -> Option < Span > {
778
778
struct LateBoundRegionsDetector < ' a , ' tcx : ' a > {
779
779
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
780
780
binder_depth : u32 ,
781
- has_late_bound_regions : bool ,
781
+ has_late_bound_regions : Option < Span > ,
782
782
}
783
783
784
784
impl < ' a , ' tcx > Visitor < ' tcx > for LateBoundRegionsDetector < ' a , ' tcx > {
@@ -787,7 +787,7 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
787
787
}
788
788
789
789
fn visit_ty ( & mut self , ty : & ' tcx hir:: Ty ) {
790
- if self . has_late_bound_regions { return }
790
+ if self . has_late_bound_regions . is_some ( ) { return }
791
791
match ty. node {
792
792
hir:: TyBareFn ( ..) => {
793
793
self . binder_depth += 1 ;
@@ -801,35 +801,35 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
801
801
fn visit_poly_trait_ref ( & mut self ,
802
802
tr : & ' tcx hir:: PolyTraitRef ,
803
803
m : hir:: TraitBoundModifier ) {
804
- if self . has_late_bound_regions { return }
804
+ if self . has_late_bound_regions . is_some ( ) { return }
805
805
self . binder_depth += 1 ;
806
806
intravisit:: walk_poly_trait_ref ( self , tr, m) ;
807
807
self . binder_depth -= 1 ;
808
808
}
809
809
810
810
fn visit_lifetime ( & mut self , lt : & ' tcx hir:: Lifetime ) {
811
- if self . has_late_bound_regions { return }
811
+ if self . has_late_bound_regions . is_some ( ) { return }
812
812
813
813
match self . tcx . named_region_map . defs . get ( & lt. id ) . cloned ( ) {
814
814
Some ( rl:: Region :: Static ) | Some ( rl:: Region :: EarlyBound ( ..) ) => { }
815
815
Some ( rl:: Region :: LateBound ( debruijn, _) ) |
816
816
Some ( rl:: Region :: LateBoundAnon ( debruijn, _) )
817
817
if debruijn. depth < self . binder_depth => { }
818
- _ => self . has_late_bound_regions = true ,
818
+ _ => self . has_late_bound_regions = Some ( lt . span ) ,
819
819
}
820
820
}
821
821
}
822
822
823
823
fn has_late_bound_regions < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
824
824
generics : & ' tcx hir:: Generics ,
825
825
decl : & ' tcx hir:: FnDecl )
826
- -> bool {
826
+ -> Option < Span > {
827
827
let mut visitor = LateBoundRegionsDetector {
828
- tcx, binder_depth : 1 , has_late_bound_regions : false
828
+ tcx, binder_depth : 1 , has_late_bound_regions : None
829
829
} ;
830
830
for lifetime in & generics. lifetimes {
831
831
if tcx. named_region_map . late_bound . contains ( & lifetime. lifetime . id ) {
832
- return true ;
832
+ return Some ( lifetime . lifetime . span ) ;
833
833
}
834
834
}
835
835
visitor. visit_fn_decl ( decl) ;
@@ -840,24 +840,24 @@ fn has_late_bound_regions<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
840
840
hir_map:: NodeTraitItem ( item) => match item. node {
841
841
hir:: TraitItemKind :: Method ( ref sig, _) =>
842
842
has_late_bound_regions ( tcx, & sig. generics , & sig. decl ) ,
843
- _ => false ,
843
+ _ => None ,
844
844
} ,
845
845
hir_map:: NodeImplItem ( item) => match item. node {
846
846
hir:: ImplItemKind :: Method ( ref sig, _) =>
847
847
has_late_bound_regions ( tcx, & sig. generics , & sig. decl ) ,
848
- _ => false ,
848
+ _ => None ,
849
849
} ,
850
850
hir_map:: NodeForeignItem ( item) => match item. node {
851
851
hir:: ForeignItemFn ( ref fn_decl, _, ref generics) =>
852
852
has_late_bound_regions ( tcx, generics, fn_decl) ,
853
- _ => false ,
853
+ _ => None ,
854
854
} ,
855
855
hir_map:: NodeItem ( item) => match item. node {
856
856
hir:: ItemFn ( ref fn_decl, .., ref generics, _) =>
857
857
has_late_bound_regions ( tcx, generics, fn_decl) ,
858
- _ => false ,
858
+ _ => None ,
859
859
} ,
860
- _ => false
860
+ _ => None
861
861
}
862
862
}
863
863
0 commit comments