@@ -72,13 +72,13 @@ pub enum LifetimeSource {
7272#[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable_Generic ) ]
7373pub enum LifetimeSyntax {
7474 /// E.g. `&Type`, `ContainsLifetime`
75- Hidden ,
75+ Implicit ,
7676
7777 /// E.g. `&'_ Type`, `ContainsLifetime<'_>`, `impl Trait + '_`, `impl Trait + use<'_>`
78- Anonymous ,
78+ ExplicitAnonymous ,
7979
8080 /// E.g. `&'a Type`, `ContainsLifetime<'a>`, `impl Trait + 'a`, `impl Trait + use<'a>`
81- Named ,
81+ ExplicitBound ,
8282}
8383
8484impl From < Ident > for LifetimeSyntax {
@@ -88,10 +88,10 @@ impl From<Ident> for LifetimeSyntax {
8888 if name == sym:: empty {
8989 unreachable ! ( "A lifetime name should never be empty" ) ;
9090 } else if name == kw:: UnderscoreLifetime {
91- LifetimeSyntax :: Anonymous
91+ LifetimeSyntax :: ExplicitAnonymous
9292 } else {
9393 debug_assert ! ( name. as_str( ) . starts_with( '\'' ) ) ;
94- LifetimeSyntax :: Named
94+ LifetimeSyntax :: ExplicitBound
9595 }
9696 }
9797}
@@ -102,48 +102,48 @@ impl From<Ident> for LifetimeSyntax {
102102///
103103/// ```
104104/// #[repr(C)]
105- /// struct S<'a>(&'a u32); // res=Param, name='a, source=Reference, syntax=Named
105+ /// struct S<'a>(&'a u32); // res=Param, name='a, source=Reference, syntax=ExplicitBound
106106/// unsafe extern "C" {
107- /// fn f1(s: S); // res=Param, name='_, source=Path, syntax=Hidden
108- /// fn f2(s: S<'_>); // res=Param, name='_, source=Path, syntax=Anonymous
109- /// fn f3<'a>(s: S<'a>); // res=Param, name='a, source=Path, syntax=Named
107+ /// fn f1(s: S); // res=Param, name='_, source=Path, syntax=Implicit
108+ /// fn f2(s: S<'_>); // res=Param, name='_, source=Path, syntax=ExplicitAnonymous
109+ /// fn f3<'a>(s: S<'a>); // res=Param, name='a, source=Path, syntax=ExplicitBound
110110/// }
111111///
112- /// struct St<'a> { x: &'a u32 } // res=Param, name='a, source=Reference, syntax=Named
112+ /// struct St<'a> { x: &'a u32 } // res=Param, name='a, source=Reference, syntax=ExplicitBound
113113/// fn f() {
114- /// _ = St { x: &0 }; // res=Infer, name='_, source=Path, syntax=Hidden
115- /// _ = St::<'_> { x: &0 }; // res=Infer, name='_, source=Path, syntax=Anonymous
114+ /// _ = St { x: &0 }; // res=Infer, name='_, source=Path, syntax=Implicit
115+ /// _ = St::<'_> { x: &0 }; // res=Infer, name='_, source=Path, syntax=ExplicitAnonymous
116116/// }
117117///
118- /// struct Name<'a>(&'a str); // res=Param, name='a, source=Reference, syntax=Named
119- /// const A: Name = Name("a"); // res=Static, name='_, source=Path, syntax=Hidden
120- /// const B: &str = ""; // res=Static, name='_, source=Reference, syntax=Hidden
121- /// static C: &'_ str = ""; // res=Static, name='_, source=Reference, syntax=Anonymous
122- /// static D: &'static str = ""; // res=Static, name='static, source=Reference, syntax=Named
118+ /// struct Name<'a>(&'a str); // res=Param, name='a, source=Reference, syntax=ExplicitBound
119+ /// const A: Name = Name("a"); // res=Static, name='_, source=Path, syntax=Implicit
120+ /// const B: &str = ""; // res=Static, name='_, source=Reference, syntax=Implicit
121+ /// static C: &'_ str = ""; // res=Static, name='_, source=Reference, syntax=ExplicitAnonymous
122+ /// static D: &'static str = ""; // res=Static, name='static, source=Reference, syntax=ExplicitBound
123123///
124124/// trait Tr {}
125- /// fn tr(_: Box<dyn Tr>) {} // res=ImplicitObjectLifetimeDefault, name='_, source=Other, syntax=Hidden
125+ /// fn tr(_: Box<dyn Tr>) {} // res=ImplicitObjectLifetimeDefault, name='_, source=Other, syntax=Implicit
126126///
127127/// fn capture_outlives<'a>() ->
128- /// impl FnOnce() + 'a // res=Param, ident='a, source=OutlivesBound, syntax=Named
128+ /// impl FnOnce() + 'a // res=Param, ident='a, source=OutlivesBound, syntax=ExplicitBound
129129/// {
130130/// || {}
131131/// }
132132///
133133/// fn capture_precise<'a>() ->
134- /// impl FnOnce() + use<'a> // res=Param, ident='a, source=PreciseCapturing, syntax=Named
134+ /// impl FnOnce() + use<'a> // res=Param, ident='a, source=PreciseCapturing, syntax=ExplicitBound
135135/// {
136136/// || {}
137137/// }
138138///
139139/// // (commented out because these cases trigger errors)
140- /// // struct S1<'a>(&'a str); // res=Param, name='a, source=Reference, syntax=Named
141- /// // struct S2(S1); // res=Error, name='_, source=Path, syntax=Hidden
142- /// // struct S3(S1<'_>); // res=Error, name='_, source=Path, syntax=Anonymous
143- /// // struct S4(S1<'a>); // res=Error, name='a, source=Path, syntax=Named
140+ /// // struct S1<'a>(&'a str); // res=Param, name='a, source=Reference, syntax=ExplicitBound
141+ /// // struct S2(S1); // res=Error, name='_, source=Path, syntax=Implicit
142+ /// // struct S3(S1<'_>); // res=Error, name='_, source=Path, syntax=ExplicitAnonymous
143+ /// // struct S4(S1<'a>); // res=Error, name='a, source=Path, syntax=ExplicitBound
144144/// ```
145145///
146- /// Some combinations that cannot occur are `LifetimeSyntax::Hidden ` with
146+ /// Some combinations that cannot occur are `LifetimeSyntax::Implicit ` with
147147/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
148148/// — there's no way to "elide" these lifetimes.
149149#[ derive( Debug , Copy , Clone , HashStable_Generic ) ]
@@ -206,7 +206,7 @@ impl ParamName {
206206 }
207207}
208208
209- #[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable_Generic ) ]
209+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , HashStable_Generic ) ]
210210pub enum LifetimeKind {
211211 /// User-given names or fresh (synthetic) names.
212212 Param ( LocalDefId ) ,
@@ -287,12 +287,8 @@ impl Lifetime {
287287 self . ident . name == kw:: UnderscoreLifetime
288288 }
289289
290- pub fn is_syntactically_hidden ( & self ) -> bool {
291- matches ! ( self . syntax, LifetimeSyntax :: Hidden )
292- }
293-
294- pub fn is_syntactically_anonymous ( & self ) -> bool {
295- matches ! ( self . syntax, LifetimeSyntax :: Anonymous )
290+ pub fn is_implicit ( & self ) -> bool {
291+ matches ! ( self . syntax, LifetimeSyntax :: Implicit )
296292 }
297293
298294 pub fn is_static ( & self ) -> bool {
@@ -307,28 +303,28 @@ impl Lifetime {
307303
308304 match ( self . syntax , self . source ) {
309305 // The user wrote `'a` or `'_`.
310- ( Named | Anonymous , _) => ( self . ident . span , format ! ( "{new_lifetime}" ) ) ,
306+ ( ExplicitBound | ExplicitAnonymous , _) => ( self . ident . span , format ! ( "{new_lifetime}" ) ) ,
311307
312308 // The user wrote `Path<T>`, and omitted the `'_,`.
313- ( Hidden , Path { angle_brackets : AngleBrackets :: Full } ) => {
309+ ( Implicit , Path { angle_brackets : AngleBrackets :: Full } ) => {
314310 ( self . ident . span , format ! ( "{new_lifetime}, " ) )
315311 }
316312
317313 // The user wrote `Path<>`, and omitted the `'_`..
318- ( Hidden , Path { angle_brackets : AngleBrackets :: Empty } ) => {
314+ ( Implicit , Path { angle_brackets : AngleBrackets :: Empty } ) => {
319315 ( self . ident . span , format ! ( "{new_lifetime}" ) )
320316 }
321317
322318 // The user wrote `Path` and omitted the `<'_>`.
323- ( Hidden , Path { angle_brackets : AngleBrackets :: Missing } ) => {
319+ ( Implicit , Path { angle_brackets : AngleBrackets :: Missing } ) => {
324320 ( self . ident . span . shrink_to_hi ( ) , format ! ( "<{new_lifetime}>" ) )
325321 }
326322
327323 // The user wrote `&type` or `&mut type`.
328- ( Hidden , Reference ) => ( self . ident . span , format ! ( "{new_lifetime} " ) ) ,
324+ ( Implicit , Reference ) => ( self . ident . span , format ! ( "{new_lifetime} " ) ) ,
329325
330- ( Hidden , source) => {
331- unreachable ! ( "can't suggest for a hidden lifetime of {source:?}" )
326+ ( Implicit , source) => {
327+ unreachable ! ( "can't suggest for a implicit lifetime of {source:?}" )
332328 }
333329 }
334330 }
0 commit comments