@@ -142,13 +142,9 @@ struct LoweringContext<'a, 'hir: 'a> {
142142 /// indicate whether or not we're in a place where new lifetimes will result
143143 /// in in-band lifetime definitions, such a function or an impl header,
144144 /// including implicit lifetimes from `impl_header_lifetime_elision`.
145- is_collecting_in_band_lifetimes : bool ,
145+ is_collecting_anonymous_lifetimes : bool ,
146146
147147 /// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
148- /// When `is_collecting_in_band_lifetimes` is true, each lifetime is checked
149- /// against this list to see if it is already in-scope, or if a definition
150- /// needs to be created for it.
151- ///
152148 /// We always store a `normalize_to_macros_2_0()` version of the param-name in this
153149 /// vector.
154150 in_scope_lifetimes : Vec < ParamName > ,
@@ -379,7 +375,7 @@ pub fn lower_crate<'a, 'hir>(
379375 task_context : None ,
380376 current_item : None ,
381377 lifetimes_to_define : Vec :: new ( ) ,
382- is_collecting_in_band_lifetimes : false ,
378+ is_collecting_anonymous_lifetimes : false ,
383379 in_scope_lifetimes : Vec :: new ( ) ,
384380 allow_try_trait : Some ( [ sym:: try_trait_v2] [ ..] . into ( ) ) ,
385381 allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
@@ -726,13 +722,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
726722 & mut self ,
727723 f : impl FnOnce ( & mut Self ) -> T ,
728724 ) -> ( Vec < ( Span , ParamName ) > , T ) {
729- let was_collecting = std:: mem:: replace ( & mut self . is_collecting_in_band_lifetimes , true ) ;
725+ let was_collecting = std:: mem:: replace ( & mut self . is_collecting_anonymous_lifetimes , true ) ;
730726 let len = self . lifetimes_to_define . len ( ) ;
731727
732728 let res = f ( self ) ;
733729
734730 let lifetimes_to_define = self . lifetimes_to_define . split_off ( len) ;
735- self . is_collecting_in_band_lifetimes = was_collecting;
731+ self . is_collecting_anonymous_lifetimes = was_collecting;
736732 ( lifetimes_to_define, res)
737733 }
738734
@@ -749,7 +745,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
749745 // that collisions are ok here and this shouldn't
750746 // really show up for end-user.
751747 let ( str_name, kind) = match hir_name {
752- ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: InBand ) ,
748+ ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: Explicit ) ,
753749 ParamName :: Fresh ( _) => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Elided ) ,
754750 ParamName :: Error => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Error ) ,
755751 } ;
@@ -773,38 +769,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
773769 }
774770 }
775771
776- /// When there is a reference to some lifetime `'a`, and in-band
777- /// lifetimes are enabled, then we want to push that lifetime into
778- /// the vector of names to define later. In that case, it will get
779- /// added to the appropriate generics.
780- fn maybe_collect_in_band_lifetime ( & mut self , ident : Ident ) {
781- if !self . is_collecting_in_band_lifetimes {
782- return ;
783- }
784-
785- if !self . sess . features_untracked ( ) . in_band_lifetimes {
786- return ;
787- }
788-
789- if self . in_scope_lifetimes . contains ( & ParamName :: Plain ( ident. normalize_to_macros_2_0 ( ) ) ) {
790- return ;
791- }
792-
793- let hir_name = ParamName :: Plain ( ident) ;
794-
795- if self . lifetimes_to_define . iter ( ) . any ( |( _, lt_name) | {
796- lt_name. normalize_to_macros_2_0 ( ) == hir_name. normalize_to_macros_2_0 ( )
797- } ) {
798- return ;
799- }
800-
801- self . lifetimes_to_define . push ( ( ident. span , hir_name) ) ;
802- }
803-
804772 /// When we have either an elided or `'_` lifetime in an impl
805773 /// header, we convert it to an in-band lifetime.
806- fn collect_fresh_in_band_lifetime ( & mut self , span : Span ) -> ParamName {
807- assert ! ( self . is_collecting_in_band_lifetimes ) ;
774+ fn collect_fresh_anonymous_lifetime ( & mut self , span : Span ) -> ParamName {
775+ assert ! ( self . is_collecting_anonymous_lifetimes ) ;
808776 let index = self . lifetimes_to_define . len ( ) + self . in_scope_lifetimes . len ( ) ;
809777 let hir_name = ParamName :: Fresh ( index) ;
810778 self . lifetimes_to_define . push ( ( span, hir_name) ) ;
@@ -1946,7 +1914,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19461914 }
19471915 ident if ident. name == kw:: UnderscoreLifetime => match self . anonymous_lifetime_mode {
19481916 AnonymousLifetimeMode :: CreateParameter => {
1949- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
1917+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
19501918 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( fresh_name) )
19511919 }
19521920
@@ -1957,7 +1925,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19571925 AnonymousLifetimeMode :: ReportError => self . new_error_lifetime ( Some ( l. id ) , span) ,
19581926 } ,
19591927 ident => {
1960- self . maybe_collect_in_band_lifetime ( ident) ;
19611928 let param_name = ParamName :: Plain ( self . lower_ident ( ident) ) ;
19621929 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( param_name) )
19631930 }
@@ -2001,8 +1968,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20011968
20021969 let ( name, kind) = match param. kind {
20031970 GenericParamKind :: Lifetime => {
2004- let was_collecting_in_band = self . is_collecting_in_band_lifetimes ;
2005- self . is_collecting_in_band_lifetimes = false ;
1971+ let was_collecting_in_band = self . is_collecting_anonymous_lifetimes ;
1972+ self . is_collecting_anonymous_lifetimes = false ;
20061973
20071974 let lt = self
20081975 . with_anonymous_lifetime_mode ( AnonymousLifetimeMode :: ReportError , |this| {
@@ -2025,7 +1992,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20251992 let kind =
20261993 hir:: GenericParamKind :: Lifetime { kind : hir:: LifetimeParamKind :: Explicit } ;
20271994
2028- self . is_collecting_in_band_lifetimes = was_collecting_in_band;
1995+ self . is_collecting_anonymous_lifetimes = was_collecting_in_band;
20291996
20301997 ( param_name, kind)
20311998 }
@@ -2384,7 +2351,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23842351 // Hence `impl Foo for &u32` becomes `impl<'f> Foo for &'f u32` for some fresh
23852352 // `'f`.
23862353 AnonymousLifetimeMode :: CreateParameter => {
2387- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
2354+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
23882355 hir:: Lifetime {
23892356 hir_id : self . next_id ( ) ,
23902357 span : self . lower_span ( span) ,
0 commit comments