@@ -209,6 +209,21 @@ pub enum LifetimeName {
209209    /// User typed `'_`. 
210210     Underscore , 
211211
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+ 
212227    /// User wrote `'static` 
213228     Static , 
214229
@@ -221,7 +236,7 @@ impl LifetimeName {
221236        use  self :: LifetimeName :: * ; 
222237        match  * self  { 
223238            Implicit  => keywords:: Invalid . name ( ) , 
224-             Underscore  => keywords:: UnderscoreLifetime . name ( ) , 
239+             Fresh ( _ )  |  Underscore  => keywords:: UnderscoreLifetime . name ( ) , 
225240            Static  => keywords:: StaticLifetime . name ( ) , 
226241            Name ( name)  => name, 
227242        } 
@@ -242,7 +257,13 @@ impl Lifetime {
242257        use  self :: LifetimeName :: * ; 
243258        match  self . name  { 
244259            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 , 
246267        } 
247268    } 
248269
0 commit comments