@@ -209,6 +209,21 @@ pub enum LifetimeName {
209
209
/// User typed `'_`.
210
210
Underscore ,
211
211
212
+ /// Synthetic name generated when user elided a lifetime in an impl header,
213
+ /// e.g. the lifetimes in cases like these:
214
+ ///
215
+ /// impl Foo for &u32
216
+ /// impl Foo<'_> for u32
217
+ ///
218
+ /// in that case, we rewrite to
219
+ ///
220
+ /// impl<'f> Foo for &'f u32
221
+ /// impl<'f> Foo<'f> for u32
222
+ ///
223
+ /// where `'f` is something like `Fresh(0)`. The indices are
224
+ /// unique per impl, but not necessarily continuous.
225
+ Fresh ( usize ) ,
226
+
212
227
/// User wrote `'static`
213
228
Static ,
214
229
@@ -221,7 +236,7 @@ impl LifetimeName {
221
236
use self :: LifetimeName :: * ;
222
237
match * self {
223
238
Implicit => keywords:: Invalid . name ( ) ,
224
- Underscore => keywords:: UnderscoreLifetime . name ( ) ,
239
+ Fresh ( _ ) | Underscore => keywords:: UnderscoreLifetime . name ( ) ,
225
240
Static => keywords:: StaticLifetime . name ( ) ,
226
241
Name ( name) => name,
227
242
}
@@ -242,7 +257,13 @@ impl Lifetime {
242
257
use self :: LifetimeName :: * ;
243
258
match self . name {
244
259
Implicit | Underscore => true ,
245
- Static | Name ( _) => false ,
260
+
261
+ // It might seem surprising that `Fresh(_)` counts as
262
+ // *not* elided -- but this is because, as far as the code
263
+ // in the compiler is concerned -- `Fresh(_)` variants act
264
+ // equivalently to "some fresh name". They correspond to
265
+ // early-bound regions on an impl, in other words.
266
+ Fresh ( _) | Static | Name ( _) => false ,
246
267
}
247
268
}
248
269
0 commit comments