@@ -908,7 +908,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
908908 } )
909909 . collect ( ) ;
910910 if !lifetimes. is_empty ( ) {
911- self . trait_ref_hack = true ;
912911 let next_early_index = self . next_early_index ( ) ;
913912 let scope = Scope :: Binder {
914913 lifetimes,
@@ -920,9 +919,10 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
920919 let result = self . with ( scope, |old_scope, this| {
921920 this. check_lifetime_params ( old_scope, & bound_generic_params) ;
922921 this. visit_ty ( & bounded_ty) ;
922+ this. trait_ref_hack = true ;
923923 walk_list ! ( this, visit_param_bound, bounds) ;
924+ this. trait_ref_hack = false ;
924925 } ) ;
925- self . trait_ref_hack = false ;
926926 result
927927 } else {
928928 self . visit_ty ( & bounded_ty) ;
@@ -957,13 +957,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
957957 debug ! ( "visit_poly_trait_ref(trait_ref={:?})" , trait_ref) ;
958958
959959 let should_pop_missing_lt = self . is_trait_ref_fn_scope ( trait_ref) ;
960- if !self . trait_ref_hack
960+
961+ let trait_ref_hack = take ( & mut self . trait_ref_hack ) ;
962+ if !trait_ref_hack
961963 || trait_ref. bound_generic_params . iter ( ) . any ( |param| match param. kind {
962964 GenericParamKind :: Lifetime { .. } => true ,
963965 _ => false ,
964966 } )
965967 {
966- if self . trait_ref_hack {
968+ if trait_ref_hack {
967969 struct_span_err ! (
968970 self . tcx. sess,
969971 trait_ref. span,
@@ -993,10 +995,11 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
993995 this. check_lifetime_params ( old_scope, & trait_ref. bound_generic_params ) ;
994996 walk_list ! ( this, visit_generic_param, trait_ref. bound_generic_params) ;
995997 this. visit_trait_ref ( & trait_ref. trait_ref ) ;
996- } )
998+ } ) ;
997999 } else {
9981000 self . visit_trait_ref ( & trait_ref. trait_ref ) ;
9991001 }
1002+ self . trait_ref_hack = trait_ref_hack;
10001003 if should_pop_missing_lt {
10011004 self . missing_named_lifetime_spots . pop ( ) ;
10021005 }
0 commit comments