@@ -646,26 +646,26 @@ struct DiagMetadata<'ast> {
646
646
}
647
647
648
648
#[ derive( Debug ) ]
649
- enum ResolvedElisionTarget {
650
- /// Elision in `&u8` -> `&'_ u8`
649
+ enum HiddenLifetimeTarget {
650
+ /// Lifetime in `&u8` is hidden (becomes `&'_ u8`)
651
651
TopLevel ( NodeId ) ,
652
- /// Elision in `Foo` -> `Foo<'_>`
653
- Nested ( NestedResolvedElisionTarget ) ,
652
+ /// Lifetime in `Foo` is hidden (becomes `Foo<'_>`)
653
+ Nested ( NestedHiddenLifetimeTarget ) ,
654
654
}
655
655
656
- impl ResolvedElisionTarget {
656
+ impl HiddenLifetimeTarget {
657
657
fn node_id ( & self ) -> NodeId {
658
658
match * self {
659
659
Self :: TopLevel ( n) => n,
660
- Self :: Nested ( NestedResolvedElisionTarget { segment_id, .. } ) => segment_id,
660
+ Self :: Nested ( NestedHiddenLifetimeTarget { segment_id, .. } ) => segment_id,
661
661
}
662
662
}
663
663
}
664
664
665
665
#[ derive( Debug ) ]
666
- struct NestedResolvedElisionTarget {
666
+ struct NestedHiddenLifetimeTarget {
667
667
segment_id : NodeId ,
668
- elided_lifetime_span : Span ,
668
+ lifetime_span : Span ,
669
669
diagnostic : lint:: BuiltinLintDiag ,
670
670
}
671
671
@@ -710,8 +710,8 @@ struct LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
710
710
/// Count the number of places a lifetime is used.
711
711
lifetime_uses : FxHashMap < LocalDefId , LifetimeUseSet > ,
712
712
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 > ,
715
715
}
716
716
717
717
/// 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> {
1325
1325
// errors at module scope should always be reported
1326
1326
in_func_body : false ,
1327
1327
lifetime_uses : Default :: default ( ) ,
1328
- resolved_lifetime_elisions : Vec :: new ( ) ,
1328
+ hidden_lifetimes : Vec :: new ( ) ,
1329
1329
}
1330
1330
}
1331
1331
@@ -1760,7 +1760,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1760
1760
) ;
1761
1761
self . resolve_anonymous_lifetime ( & lt, true ) ;
1762
1762
1763
- self . resolved_lifetime_elisions . push ( ResolvedElisionTarget :: TopLevel ( anchor_id) ) ;
1763
+ self . hidden_lifetimes . push ( HiddenLifetimeTarget :: TopLevel ( anchor_id) ) ;
1764
1764
}
1765
1765
1766
1766
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -1972,10 +1972,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
1972
1972
}
1973
1973
1974
1974
if should_lint {
1975
- self . resolved_lifetime_elisions . push ( ResolvedElisionTarget :: Nested (
1976
- NestedResolvedElisionTarget {
1975
+ self . hidden_lifetimes . push ( HiddenLifetimeTarget :: Nested (
1976
+ NestedHiddenLifetimeTarget {
1977
1977
segment_id,
1978
- elided_lifetime_span,
1978
+ lifetime_span : elided_lifetime_span,
1979
1979
diagnostic : lint:: BuiltinLintDiag :: ElidedLifetimesInPaths (
1980
1980
expected_lifetimes,
1981
1981
path_span,
@@ -2026,12 +2026,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2026
2026
inputs : impl Iterator < Item = ( Option < & ' ast Pat > , & ' ast Ty ) > + Clone ,
2027
2027
output_ty : & ' ast FnRetTy ,
2028
2028
) {
2029
- let outer_resolved_lifetime_elisions = take ( & mut self . resolved_lifetime_elisions ) ;
2029
+ let outer_hidden_lifetimes = take ( & mut self . hidden_lifetimes ) ;
2030
2030
2031
2031
// Add each argument to the rib.
2032
2032
let elision_lifetime = self . resolve_fn_params ( has_self, inputs) ;
2033
2033
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 ) ;
2035
2035
2036
2036
let outer_failures = take ( & mut self . diag_metadata . current_elision_failures ) ;
2037
2037
@@ -2059,31 +2059,30 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2059
2059
}
2060
2060
} ;
2061
2061
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.
2064
2064
//
2065
2065
// Our primary lint case is when an output lifetime is tied to
2066
2066
// an input lifetime. In that case, we want to warn about any
2067
2067
// nested hidden lifetimes in those params or outputs.
2068
2068
//
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.
2071
2071
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) ;
2074
2073
2075
- match ( output_resolved_lifetime_elisions . is_empty ( ) , elision_lifetime) {
2074
+ match ( output_hidden_lifetimes . is_empty ( ) , elision_lifetime) {
2076
2075
( true , _) | ( _, None ) => {
2077
2076
// 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 ,
2081
2080
) ;
2082
2081
}
2083
2082
( false , Some ( elision_lifetime) ) => {
2084
2083
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
2087
2086
let lvl1 = & self . r . lifetimes_res_map [ & re. node_id ( ) ] ;
2088
2087
let lvl2 = match lvl1 {
2089
2088
LifetimeRes :: ElidedAnchor { start, .. } => {
@@ -2095,32 +2094,32 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2095
2094
lvl2 == & elision_lifetime
2096
2095
} ) ;
2097
2096
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 ,
2101
2100
) ;
2102
- self . report_elided_lifetimes_in_paths (
2101
+ self . report_lifetimes_hidden_in_paths (
2103
2102
secondary,
2104
- lint:: builtin:: ELIDED_LIFETIMES_IN_PATHS_UNTIED ,
2103
+ lint:: builtin:: UNTIED_LIFETIMES_HIDDEN_IN_PATHS ,
2105
2104
) ;
2106
2105
}
2107
2106
}
2108
2107
}
2109
2108
2110
- fn report_elided_lifetimes_in_paths (
2109
+ fn report_lifetimes_hidden_in_paths (
2111
2110
& mut self ,
2112
- resolved_elisions : impl IntoIterator < Item = ResolvedElisionTarget > ,
2111
+ hidden_lifetimes : impl IntoIterator < Item = HiddenLifetimeTarget > ,
2113
2112
lint : & ' static lint:: Lint ,
2114
2113
) {
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 } ;
2117
2116
2118
- let NestedResolvedElisionTarget { segment_id, elided_lifetime_span , diagnostic } = d ;
2117
+ let NestedHiddenLifetimeTarget { segment_id, lifetime_span , diagnostic } = n ;
2119
2118
2120
2119
self . r . lint_buffer . buffer_lint_with_diagnostic (
2121
2120
lint,
2122
2121
segment_id,
2123
- elided_lifetime_span ,
2122
+ lifetime_span ,
2124
2123
"hidden lifetime parameters in types are deprecated" ,
2125
2124
diagnostic,
2126
2125
) ;
0 commit comments