@@ -883,7 +883,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
883883 } )
884884 . collect ( ) ;
885885 if !lifetimes. is_empty ( ) {
886- self . trait_ref_hack = true ;
887886 let next_early_index = self . next_early_index ( ) ;
888887 let scope = Scope :: Binder {
889888 lifetimes,
@@ -895,9 +894,10 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
895894 let result = self . with ( scope, |old_scope, this| {
896895 this. check_lifetime_params ( old_scope, & bound_generic_params) ;
897896 this. visit_ty ( & bounded_ty) ;
897+ this. trait_ref_hack = true ;
898898 walk_list ! ( this, visit_param_bound, bounds) ;
899+ this. trait_ref_hack = false ;
899900 } ) ;
900- self . trait_ref_hack = false ;
901901 result
902902 } else {
903903 self . visit_ty ( & bounded_ty) ;
@@ -932,13 +932,15 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
932932 debug ! ( "visit_poly_trait_ref(trait_ref={:?})" , trait_ref) ;
933933
934934 let should_pop_missing_lt = self . is_trait_ref_fn_scope ( trait_ref) ;
935- if !self . trait_ref_hack
935+
936+ let trait_ref_hack = take ( & mut self . trait_ref_hack ) ;
937+ if !trait_ref_hack
936938 || trait_ref. bound_generic_params . iter ( ) . any ( |param| match param. kind {
937939 GenericParamKind :: Lifetime { .. } => true ,
938940 _ => false ,
939941 } )
940942 {
941- if self . trait_ref_hack {
943+ if trait_ref_hack {
942944 struct_span_err ! (
943945 self . tcx. sess,
944946 trait_ref. span,
@@ -968,10 +970,11 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
968970 this. check_lifetime_params ( old_scope, & trait_ref. bound_generic_params ) ;
969971 walk_list ! ( this, visit_generic_param, trait_ref. bound_generic_params) ;
970972 this. visit_trait_ref ( & trait_ref. trait_ref ) ;
971- } )
973+ } ) ;
972974 } else {
973975 self . visit_trait_ref ( & trait_ref. trait_ref ) ;
974976 }
977+ self . trait_ref_hack = trait_ref_hack;
975978 if should_pop_missing_lt {
976979 self . missing_named_lifetime_spots . pop ( ) ;
977980 }
0 commit comments