@@ -646,26 +646,26 @@ struct DiagMetadata<'ast> {
646646}
647647
648648#[ derive( Debug ) ]
649- enum ResolvedElisionTarget {
650- /// Elision in `&u8` -> `&'_ u8`
649+ enum HiddenLifetimeTarget {
650+ /// Lifetime in `&u8` is hidden (becomes `&'_ u8`)
651651 TopLevel ( NodeId ) ,
652- /// Elision in `Foo` -> `Foo<'_>`
653- Nested ( NestedResolvedElisionTarget ) ,
652+ /// Lifetime in `Foo` is hidden (becomes `Foo<'_>`)
653+ Nested ( NestedHiddenLifetimeTarget ) ,
654654}
655655
656- impl ResolvedElisionTarget {
656+ impl HiddenLifetimeTarget {
657657 fn node_id ( & self ) -> NodeId {
658658 match * self {
659659 Self :: TopLevel ( n) => n,
660- Self :: Nested ( NestedResolvedElisionTarget { segment_id, .. } ) => segment_id,
660+ Self :: Nested ( NestedHiddenLifetimeTarget { segment_id, .. } ) => segment_id,
661661 }
662662 }
663663}
664664
665665#[ derive( Debug ) ]
666- struct NestedResolvedElisionTarget {
666+ struct NestedHiddenLifetimeTarget {
667667 segment_id : NodeId ,
668- elided_lifetime_span : Span ,
668+ lifetime_span : Span ,
669669 diagnostic : lint:: BuiltinLintDiag ,
670670}
671671
@@ -710,8 +710,8 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
710710 /// Count the number of places a lifetime is used.
711711 lifetime_uses : FxHashMap < LocalDefId , LifetimeUseSet > ,
712712
713- /// Track which types participated in lifetime elision
714- resolved_lifetime_elisions : Vec < ResolvedElisionTarget > ,
713+ /// Track which parameters/return values had hidden lifetimes.
714+ hidden_lifetimes : Vec < HiddenLifetimeTarget > ,
715715}
716716
717717/// Walks the whole crate in DFS order, visiting each item, resolving names as it goes.
@@ -1325,7 +1325,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
13251325 // errors at module scope should always be reported
13261326 in_func_body : false ,
13271327 lifetime_uses : Default :: default ( ) ,
1328- resolved_lifetime_elisions : Vec :: new ( ) ,
1328+ hidden_lifetimes : Vec :: new ( ) ,
13291329 }
13301330 }
13311331
@@ -1760,7 +1760,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
17601760 ) ;
17611761 self . resolve_anonymous_lifetime ( & lt, true ) ;
17621762
1763- self . resolved_lifetime_elisions . push ( ResolvedElisionTarget :: TopLevel ( anchor_id) ) ;
1763+ self . hidden_lifetimes . push ( HiddenLifetimeTarget :: TopLevel ( anchor_id) ) ;
17641764 }
17651765
17661766 #[ instrument( level = "debug" , skip( self ) ) ]
@@ -1972,10 +1972,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
19721972 }
19731973
19741974 if should_lint {
1975- self . resolved_lifetime_elisions . push ( ResolvedElisionTarget :: Nested (
1976- NestedResolvedElisionTarget {
1975+ self . hidden_lifetimes . push ( HiddenLifetimeTarget :: Nested (
1976+ NestedHiddenLifetimeTarget {
19771977 segment_id,
1978- elided_lifetime_span,
1978+ lifetime_span : elided_lifetime_span,
19791979 diagnostic : lint:: BuiltinLintDiag :: ElidedLifetimesInPaths (
19801980 expected_lifetimes,
19811981 path_span,
@@ -2026,12 +2026,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20262026 inputs : impl Iterator < Item = ( Option < & ' ast Pat > , & ' ast Ty ) > + Clone ,
20272027 output_ty : & ' ast FnRetTy ,
20282028 ) {
2029- let outer_resolved_lifetime_elisions = take ( & mut self . resolved_lifetime_elisions ) ;
2029+ let outer_hidden_lifetimes = take ( & mut self . hidden_lifetimes ) ;
20302030
20312031 // Add each argument to the rib.
20322032 let elision_lifetime = self . resolve_fn_params ( has_self, inputs) ;
20332033 debug ! ( ?elision_lifetime) ;
2034- let param_resolved_lifetime_elisions = take ( & mut self . resolved_lifetime_elisions ) ;
2034+ let param_hidden_lifetimes = take ( & mut self . hidden_lifetimes ) ;
20352035
20362036 let outer_failures = take ( & mut self . diag_metadata . current_elision_failures ) ;
20372037
@@ -2059,31 +2059,30 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20592059 }
20602060 } ;
20612061
2062- // We've recorded all elisions that occurred in the params and
2063- // outputs, categorized by top-level or nested.
2062+ // We've recorded all hidden lifetimes that occurred in the
2063+ // params and outputs, categorized by top-level or nested.
20642064 //
20652065 // Our primary lint case is when an output lifetime is tied to
20662066 // an input lifetime. In that case, we want to warn about any
20672067 // nested hidden lifetimes in those params or outputs.
20682068 //
2069- // The secondary case is for nested elisions that are not part
2070- // of the tied lifetime relationship.
2069+ // The secondary case is for nested hidden lifetimes that are
2070+ // not part of the tied lifetime relationship.
20712071
2072- let output_resolved_lifetime_elisions =
2073- replace ( & mut self . resolved_lifetime_elisions , outer_resolved_lifetime_elisions) ;
2072+ let output_hidden_lifetimes = replace ( & mut self . hidden_lifetimes , outer_hidden_lifetimes) ;
20742073
2075- match ( output_resolved_lifetime_elisions . is_empty ( ) , elision_lifetime) {
2074+ match ( output_hidden_lifetimes . is_empty ( ) , elision_lifetime) {
20762075 ( true , _) | ( _, None ) => {
20772076 // Treat all parameters as untied
2078- self . report_elided_lifetimes_in_paths (
2079- param_resolved_lifetime_elisions ,
2080- lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS_UNTIED ,
2077+ self . report_lifetimes_hidden_in_paths (
2078+ param_hidden_lifetimes ,
2079+ lint:: builtin:: UNTIED_LIFETIMES_HIDDEN_IN_PATHS ,
20812080 ) ;
20822081 }
20832082 ( false , Some ( elision_lifetime) ) => {
20842083 let ( primary, secondary) : ( Vec < _ > , Vec < _ > ) =
2085- param_resolved_lifetime_elisions . into_iter ( ) . partition ( |re| {
2086- // Recover the `NodeId` of an elided lifetime
2084+ param_hidden_lifetimes . into_iter ( ) . partition ( |re| {
2085+ // Recover the `NodeId` of a hidden lifetime
20872086 let lvl1 = & self . r . lifetimes_res_map [ & re. node_id ( ) ] ;
20882087 let lvl2 = match lvl1 {
20892088 LifetimeRes :: ElidedAnchor { start, .. } => {
@@ -2095,32 +2094,32 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20952094 lvl2 == & elision_lifetime
20962095 } ) ;
20972096
2098- self . report_elided_lifetimes_in_paths (
2099- primary. into_iter ( ) . chain ( output_resolved_lifetime_elisions ) ,
2100- lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS_TIED ,
2097+ self . report_lifetimes_hidden_in_paths (
2098+ primary. into_iter ( ) . chain ( output_hidden_lifetimes ) ,
2099+ lint:: builtin:: TIED_LIFETIMES_HIDDEN_IN_PATHS ,
21012100 ) ;
2102- self . report_elided_lifetimes_in_paths (
2101+ self . report_lifetimes_hidden_in_paths (
21032102 secondary,
2104- lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS_UNTIED ,
2103+ lint:: builtin:: UNTIED_LIFETIMES_HIDDEN_IN_PATHS ,
21052104 ) ;
21062105 }
21072106 }
21082107 }
21092108
2110- fn report_elided_lifetimes_in_paths (
2109+ fn report_lifetimes_hidden_in_paths (
21112110 & mut self ,
2112- resolved_elisions : impl IntoIterator < Item = ResolvedElisionTarget > ,
2111+ hidden_lifetimes : impl IntoIterator < Item = HiddenLifetimeTarget > ,
21132112 lint : & ' static lint:: Lint ,
21142113 ) {
2115- for re in resolved_elisions {
2116- let ResolvedElisionTarget :: Nested ( d ) = re else { continue } ;
2114+ for hl in hidden_lifetimes {
2115+ let HiddenLifetimeTarget :: Nested ( n ) = hl else { continue } ;
21172116
2118- let NestedResolvedElisionTarget { segment_id, elided_lifetime_span , diagnostic } = d ;
2117+ let NestedHiddenLifetimeTarget { segment_id, lifetime_span , diagnostic } = n ;
21192118
21202119 self . r . lint_buffer . buffer_lint_with_diagnostic (
21212120 lint,
21222121 segment_id,
2123- elided_lifetime_span ,
2122+ lifetime_span ,
21242123 "hidden lifetime parameters in types are deprecated" ,
21252124 diagnostic,
21262125 ) ;
0 commit comments