@@ -645,6 +645,13 @@ struct DiagMetadata<'ast> {
645645     current_elision_failures :  Vec < MissingLifetime > , 
646646} 
647647
648+ #[ derive( Debug ) ]  
649+ struct  ResolvedNestedElisionTarget  { 
650+     segment_id :  NodeId , 
651+     elided_lifetime_span :  Span , 
652+     diagnostic :  lint:: BuiltinLintDiag , 
653+ } 
654+ 
648655struct  LateResolutionVisitor < ' a ,  ' b ,  ' ast ,  ' tcx >  { 
649656    r :  & ' b  mut  Resolver < ' a ,  ' tcx > , 
650657
@@ -685,6 +692,9 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
685692
686693    /// Count the number of places a lifetime is used. 
687694     lifetime_uses :  FxHashMap < LocalDefId ,  LifetimeUseSet > , 
695+ 
696+     /// Track which types participated in lifetime elision 
697+      resolved_lifetime_elisions :  Vec < ResolvedNestedElisionTarget > , 
688698} 
689699
690700/// Walks the whole crate in DFS order, visiting each item, resolving names as it goes. 
@@ -1298,6 +1308,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
12981308            // errors at module scope should always be reported 
12991309            in_func_body :  false , 
13001310            lifetime_uses :  Default :: default ( ) , 
1311+             resolved_lifetime_elisions :  Vec :: new ( ) , 
13011312        } 
13021313    } 
13031314
@@ -1942,18 +1953,16 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
19421953            } 
19431954
19441955            if  should_lint { 
1945-                 self . r . lint_buffer . buffer_lint_with_diagnostic ( 
1946-                     lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS , 
1956+                 self . resolved_lifetime_elisions . push ( ResolvedNestedElisionTarget  { 
19471957                    segment_id, 
19481958                    elided_lifetime_span, 
1949-                     "hidden lifetime parameters in types are deprecated" , 
1950-                     lint:: BuiltinLintDiag :: ElidedLifetimesInPaths ( 
1959+                     diagnostic :  lint:: BuiltinLintDiag :: ElidedLifetimesInPaths ( 
19511960                        expected_lifetimes, 
19521961                        path_span, 
19531962                        !segment. has_generic_args , 
19541963                        elided_lifetime_span, 
19551964                    ) , 
1956-                 ) ; 
1965+                 } ) ; 
19571966            } 
19581967        } 
19591968    } 
@@ -1996,24 +2005,47 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
19962005        inputs :  impl  Iterator < Item  = ( Option < & ' ast  Pat > ,  & ' ast  Ty ) >  + Clone , 
19972006        output_ty :  & ' ast  FnRetTy , 
19982007    )  { 
2008+         let  outer_resolved_lifetime_elisions = take ( & mut  self . resolved_lifetime_elisions ) ; 
2009+ 
19992010        // Add each argument to the rib. 
20002011        let  elision_lifetime = self . resolve_fn_params ( has_self,  inputs) ; 
20012012        debug ! ( ?elision_lifetime) ; 
2013+         let  param_resolved_lifetime_elisions = take ( & mut  self . resolved_lifetime_elisions ) ; 
20022014
20032015        let  outer_failures = take ( & mut  self . diag_metadata . current_elision_failures ) ; 
2016+ 
20042017        let  output_rib = if  let  Ok ( res)  = elision_lifetime. as_ref ( )  { 
20052018            self . r . lifetime_elision_allowed . insert ( fn_id) ; 
20062019            LifetimeRibKind :: Elided ( * res) 
20072020        }  else  { 
20082021            LifetimeRibKind :: ElisionFailure 
20092022        } ; 
20102023        self . with_lifetime_rib ( output_rib,  |this| visit:: walk_fn_ret_ty ( this,  output_ty) ) ; 
2024+ 
20112025        let  elision_failures =
20122026            replace ( & mut  self . diag_metadata . current_elision_failures ,  outer_failures) ; 
20132027        if  !elision_failures. is_empty ( )  { 
20142028            let  Err ( failure_info)  = elision_lifetime else  {  bug ! ( )  } ; 
20152029            self . report_missing_lifetime_specifiers ( elision_failures,  Some ( failure_info) ) ; 
20162030        } 
2031+ 
2032+         let  output_resolved_lifetime_elisions =
2033+             replace ( & mut  self . resolved_lifetime_elisions ,  outer_resolved_lifetime_elisions) ; 
2034+ 
2035+         let  resolved_lifetime_elisions =
2036+             param_resolved_lifetime_elisions. into_iter ( ) . chain ( output_resolved_lifetime_elisions) ; 
2037+ 
2038+         for  re in  resolved_lifetime_elisions { 
2039+             let  ResolvedNestedElisionTarget  {  segment_id,  elided_lifetime_span,  diagnostic }  = re; 
2040+ 
2041+             self . r . lint_buffer . buffer_lint_with_diagnostic ( 
2042+                 lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS , 
2043+                 segment_id, 
2044+                 elided_lifetime_span, 
2045+                 "hidden lifetime parameters in types are deprecated" , 
2046+                 diagnostic, 
2047+             ) ; 
2048+         } 
20172049    } 
20182050
20192051    /// Resolve inside function parameters and parameter types. 
0 commit comments