@@ -141,13 +141,9 @@ struct LoweringContext<'a, 'hir: 'a> {
141141 /// indicate whether or not we're in a place where new lifetimes will result
142142 /// in in-band lifetime definitions, such a function or an impl header,
143143 /// including implicit lifetimes from `impl_header_lifetime_elision`.
144- is_collecting_in_band_lifetimes : bool ,
144+ is_collecting_anonymous_lifetimes : bool ,
145145
146146 /// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
147- /// When `is_collecting_in_band_lifetimes` is true, each lifetime is checked
148- /// against this list to see if it is already in-scope, or if a definition
149- /// needs to be created for it.
150- ///
151147 /// We always store a `normalize_to_macros_2_0()` version of the param-name in this
152148 /// vector.
153149 in_scope_lifetimes : Vec < ParamName > ,
@@ -374,7 +370,7 @@ pub fn lower_crate<'a, 'hir>(
374370 task_context : None ,
375371 current_item : None ,
376372 lifetimes_to_define : Vec :: new ( ) ,
377- is_collecting_in_band_lifetimes : false ,
373+ is_collecting_anonymous_lifetimes : false ,
378374 in_scope_lifetimes : Vec :: new ( ) ,
379375 allow_try_trait : Some ( [ sym:: try_trait_v2] [ ..] . into ( ) ) ,
380376 allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
@@ -718,13 +714,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
718714 & mut self ,
719715 f : impl FnOnce ( & mut Self ) -> T ,
720716 ) -> ( Vec < ( Span , ParamName ) > , T ) {
721- let was_collecting = std:: mem:: replace ( & mut self . is_collecting_in_band_lifetimes , true ) ;
717+ let was_collecting = std:: mem:: replace ( & mut self . is_collecting_anonymous_lifetimes , true ) ;
722718 let len = self . lifetimes_to_define . len ( ) ;
723719
724720 let res = f ( self ) ;
725721
726722 let lifetimes_to_define = self . lifetimes_to_define . split_off ( len) ;
727- self . is_collecting_in_band_lifetimes = was_collecting;
723+ self . is_collecting_anonymous_lifetimes = was_collecting;
728724 ( lifetimes_to_define, res)
729725 }
730726
@@ -741,7 +737,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
741737 // that collisions are ok here and this shouldn't
742738 // really show up for end-user.
743739 let ( str_name, kind) = match hir_name {
744- ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: InBand ) ,
740+ ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: Explicit ) ,
745741 ParamName :: Fresh ( _) => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Elided ) ,
746742 ParamName :: Error => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Error ) ,
747743 } ;
@@ -765,38 +761,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
765761 }
766762 }
767763
768- /// When there is a reference to some lifetime `'a`, and in-band
769- /// lifetimes are enabled, then we want to push that lifetime into
770- /// the vector of names to define later. In that case, it will get
771- /// added to the appropriate generics.
772- fn maybe_collect_in_band_lifetime ( & mut self , ident : Ident ) {
773- if !self . is_collecting_in_band_lifetimes {
774- return ;
775- }
776-
777- if !self . sess . features_untracked ( ) . in_band_lifetimes {
778- return ;
779- }
780-
781- if self . in_scope_lifetimes . contains ( & ParamName :: Plain ( ident. normalize_to_macros_2_0 ( ) ) ) {
782- return ;
783- }
784-
785- let hir_name = ParamName :: Plain ( ident) ;
786-
787- if self . lifetimes_to_define . iter ( ) . any ( |( _, lt_name) | {
788- lt_name. normalize_to_macros_2_0 ( ) == hir_name. normalize_to_macros_2_0 ( )
789- } ) {
790- return ;
791- }
792-
793- self . lifetimes_to_define . push ( ( ident. span , hir_name) ) ;
794- }
795-
796764 /// When we have either an elided or `'_` lifetime in an impl
797765 /// header, we convert it to an in-band lifetime.
798- fn collect_fresh_in_band_lifetime ( & mut self , span : Span ) -> ParamName {
799- assert ! ( self . is_collecting_in_band_lifetimes ) ;
766+ fn collect_fresh_anonymous_lifetime ( & mut self , span : Span ) -> ParamName {
767+ assert ! ( self . is_collecting_anonymous_lifetimes ) ;
800768 let index = self . lifetimes_to_define . len ( ) + self . in_scope_lifetimes . len ( ) ;
801769 let hir_name = ParamName :: Fresh ( index) ;
802770 self . lifetimes_to_define . push ( ( span, hir_name) ) ;
@@ -1938,7 +1906,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19381906 }
19391907 ident if ident. name == kw:: UnderscoreLifetime => match self . anonymous_lifetime_mode {
19401908 AnonymousLifetimeMode :: CreateParameter => {
1941- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
1909+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
19421910 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( fresh_name) )
19431911 }
19441912
@@ -1949,7 +1917,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19491917 AnonymousLifetimeMode :: ReportError => self . new_error_lifetime ( Some ( l. id ) , span) ,
19501918 } ,
19511919 ident => {
1952- self . maybe_collect_in_band_lifetime ( ident) ;
19531920 let param_name = ParamName :: Plain ( self . lower_ident ( ident) ) ;
19541921 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( param_name) )
19551922 }
@@ -1993,8 +1960,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19931960
19941961 let ( name, kind) = match param. kind {
19951962 GenericParamKind :: Lifetime => {
1996- let was_collecting_in_band = self . is_collecting_in_band_lifetimes ;
1997- self . is_collecting_in_band_lifetimes = false ;
1963+ let was_collecting_in_band = self . is_collecting_anonymous_lifetimes ;
1964+ self . is_collecting_anonymous_lifetimes = false ;
19981965
19991966 let lt = self
20001967 . with_anonymous_lifetime_mode ( AnonymousLifetimeMode :: ReportError , |this| {
@@ -2017,7 +1984,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20171984 let kind =
20181985 hir:: GenericParamKind :: Lifetime { kind : hir:: LifetimeParamKind :: Explicit } ;
20191986
2020- self . is_collecting_in_band_lifetimes = was_collecting_in_band;
1987+ self . is_collecting_anonymous_lifetimes = was_collecting_in_band;
20211988
20221989 ( param_name, kind)
20231990 }
@@ -2376,7 +2343,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23762343 // Hence `impl Foo for &u32` becomes `impl<'f> Foo for &'f u32` for some fresh
23772344 // `'f`.
23782345 AnonymousLifetimeMode :: CreateParameter => {
2379- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
2346+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
23802347 hir:: Lifetime {
23812348 hir_id : self . next_id ( ) ,
23822349 span : self . lower_span ( span) ,
0 commit comments