@@ -72,13 +72,13 @@ pub enum LifetimeSource {
72
72
#[ derive( Debug , Copy , Clone , PartialEq , Eq , HashStable_Generic ) ]
73
73
pub enum LifetimeSyntax {
74
74
/// E.g. `&Type`, `ContainsLifetime`
75
- Hidden ,
75
+ Implicit ,
76
76
77
77
/// E.g. `&'_ Type`, `ContainsLifetime<'_>`, `impl Trait + '_`, `impl Trait + use<'_>`
78
- Anonymous ,
78
+ ExplicitAnonymous ,
79
79
80
80
/// E.g. `&'a Type`, `ContainsLifetime<'a>`, `impl Trait + 'a`, `impl Trait + use<'a>`
81
- Named ,
81
+ ExplicitBound ,
82
82
}
83
83
84
84
impl From < Ident > for LifetimeSyntax {
@@ -88,10 +88,10 @@ impl From<Ident> for LifetimeSyntax {
88
88
if name == kw:: Empty {
89
89
unreachable ! ( "A lifetime name should never be empty" ) ;
90
90
} else if name == kw:: UnderscoreLifetime {
91
- LifetimeSyntax :: Anonymous
91
+ LifetimeSyntax :: ExplicitAnonymous
92
92
} else {
93
93
debug_assert ! ( name. as_str( ) . starts_with( '\'' ) ) ;
94
- LifetimeSyntax :: Named
94
+ LifetimeSyntax :: ExplicitBound
95
95
}
96
96
}
97
97
}
@@ -102,48 +102,48 @@ impl From<Ident> for LifetimeSyntax {
102
102
///
103
103
/// ```
104
104
/// #[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
106
106
/// 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
110
110
/// }
111
111
///
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
113
113
/// 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
116
116
/// }
117
117
///
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
123
123
///
124
124
/// 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
126
126
///
127
127
/// 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
129
129
/// {
130
130
/// || {}
131
131
/// }
132
132
///
133
133
/// 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
135
135
/// {
136
136
/// || {}
137
137
/// }
138
138
///
139
139
/// // (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
144
144
/// ```
145
145
///
146
- /// Some combinations that cannot occur are `LifetimeSyntax::Hidden ` with
146
+ /// Some combinations that cannot occur are `LifetimeSyntax::Implicit ` with
147
147
/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
148
148
/// — there's no way to "elide" these lifetimes.
149
149
#[ derive( Debug , Copy , Clone , HashStable_Generic ) ]
@@ -287,12 +287,8 @@ impl Lifetime {
287
287
self . ident . name == kw:: UnderscoreLifetime
288
288
}
289
289
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 )
296
292
}
297
293
298
294
pub fn is_static ( & self ) -> bool {
@@ -307,28 +303,28 @@ impl Lifetime {
307
303
308
304
match ( self . syntax , self . source ) {
309
305
// The user wrote `'a` or `'_`.
310
- ( Named | Anonymous , _) => ( self . ident . span , format ! ( "{new_lifetime}" ) ) ,
306
+ ( ExplicitBound | ExplicitAnonymous , _) => ( self . ident . span , format ! ( "{new_lifetime}" ) ) ,
311
307
312
308
// The user wrote `Path<T>`, and omitted the `'_,`.
313
- ( Hidden , Path { angle_brackets : AngleBrackets :: Full } ) => {
309
+ ( Implicit , Path { angle_brackets : AngleBrackets :: Full } ) => {
314
310
( self . ident . span , format ! ( "{new_lifetime}, " ) )
315
311
}
316
312
317
313
// The user wrote `Path<>`, and omitted the `'_`..
318
- ( Hidden , Path { angle_brackets : AngleBrackets :: Empty } ) => {
314
+ ( Implicit , Path { angle_brackets : AngleBrackets :: Empty } ) => {
319
315
( self . ident . span , format ! ( "{new_lifetime}" ) )
320
316
}
321
317
322
318
// The user wrote `Path` and omitted the `<'_>`.
323
- ( Hidden , Path { angle_brackets : AngleBrackets :: Missing } ) => {
319
+ ( Implicit , Path { angle_brackets : AngleBrackets :: Missing } ) => {
324
320
( self . ident . span . shrink_to_hi ( ) , format ! ( "<{new_lifetime}>" ) )
325
321
}
326
322
327
323
// 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} " ) ) ,
329
325
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:?}" )
332
328
}
333
329
}
334
330
}
0 commit comments