@@ -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 > ,
@@ -377,7 +373,7 @@ pub fn lower_crate<'a, 'hir>(
377373 task_context : None ,
378374 current_item : None ,
379375 lifetimes_to_define : Vec :: new ( ) ,
380- is_collecting_in_band_lifetimes : false ,
376+ is_collecting_anonymous_lifetimes : false ,
381377 in_scope_lifetimes : Vec :: new ( ) ,
382378 allow_try_trait : Some ( [ sym:: try_trait_v2] [ ..] . into ( ) ) ,
383379 allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
@@ -724,13 +720,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
724720 & mut self ,
725721 f : impl FnOnce ( & mut Self ) -> T ,
726722 ) -> ( Vec < ( Span , ParamName ) > , T ) {
727- let was_collecting = std:: mem:: replace ( & mut self . is_collecting_in_band_lifetimes , true ) ;
723+ let was_collecting = std:: mem:: replace ( & mut self . is_collecting_anonymous_lifetimes , true ) ;
728724 let len = self . lifetimes_to_define . len ( ) ;
729725
730726 let res = f ( self ) ;
731727
732728 let lifetimes_to_define = self . lifetimes_to_define . split_off ( len) ;
733- self . is_collecting_in_band_lifetimes = was_collecting;
729+ self . is_collecting_anonymous_lifetimes = was_collecting;
734730 ( lifetimes_to_define, res)
735731 }
736732
@@ -747,7 +743,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
747743 // that collisions are ok here and this shouldn't
748744 // really show up for end-user.
749745 let ( str_name, kind) = match hir_name {
750- ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: InBand ) ,
746+ ParamName :: Plain ( ident) => ( ident. name , hir:: LifetimeParamKind :: Explicit ) ,
751747 ParamName :: Fresh ( _) => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Elided ) ,
752748 ParamName :: Error => ( kw:: UnderscoreLifetime , hir:: LifetimeParamKind :: Error ) ,
753749 } ;
@@ -771,38 +767,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
771767 }
772768 }
773769
774- /// When there is a reference to some lifetime `'a`, and in-band
775- /// lifetimes are enabled, then we want to push that lifetime into
776- /// the vector of names to define later. In that case, it will get
777- /// added to the appropriate generics.
778- fn maybe_collect_in_band_lifetime ( & mut self , ident : Ident ) {
779- if !self . is_collecting_in_band_lifetimes {
780- return ;
781- }
782-
783- if !self . sess . features_untracked ( ) . in_band_lifetimes {
784- return ;
785- }
786-
787- if self . in_scope_lifetimes . contains ( & ParamName :: Plain ( ident. normalize_to_macros_2_0 ( ) ) ) {
788- return ;
789- }
790-
791- let hir_name = ParamName :: Plain ( ident) ;
792-
793- if self . lifetimes_to_define . iter ( ) . any ( |( _, lt_name) | {
794- lt_name. normalize_to_macros_2_0 ( ) == hir_name. normalize_to_macros_2_0 ( )
795- } ) {
796- return ;
797- }
798-
799- self . lifetimes_to_define . push ( ( ident. span , hir_name) ) ;
800- }
801-
802770 /// When we have either an elided or `'_` lifetime in an impl
803771 /// header, we convert it to an in-band lifetime.
804- fn collect_fresh_in_band_lifetime ( & mut self , span : Span ) -> ParamName {
805- assert ! ( self . is_collecting_in_band_lifetimes ) ;
772+ fn collect_fresh_anonymous_lifetime ( & mut self , span : Span ) -> ParamName {
773+ assert ! ( self . is_collecting_anonymous_lifetimes ) ;
806774 let index = self . lifetimes_to_define . len ( ) + self . in_scope_lifetimes . len ( ) ;
807775 let hir_name = ParamName :: Fresh ( index) ;
808776 self . lifetimes_to_define . push ( ( span, hir_name) ) ;
@@ -1944,7 +1912,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19441912 }
19451913 ident if ident. name == kw:: UnderscoreLifetime => match self . anonymous_lifetime_mode {
19461914 AnonymousLifetimeMode :: CreateParameter => {
1947- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
1915+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
19481916 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( fresh_name) )
19491917 }
19501918
@@ -1955,7 +1923,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19551923 AnonymousLifetimeMode :: ReportError => self . new_error_lifetime ( Some ( l. id ) , span) ,
19561924 } ,
19571925 ident => {
1958- self . maybe_collect_in_band_lifetime ( ident) ;
19591926 let param_name = ParamName :: Plain ( self . lower_ident ( ident) ) ;
19601927 self . new_named_lifetime ( l. id , span, hir:: LifetimeName :: Param ( param_name) )
19611928 }
@@ -1999,8 +1966,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19991966
20001967 let ( name, kind) = match param. kind {
20011968 GenericParamKind :: Lifetime => {
2002- let was_collecting_in_band = self . is_collecting_in_band_lifetimes ;
2003- self . is_collecting_in_band_lifetimes = false ;
1969+ let was_collecting_in_band = self . is_collecting_anonymous_lifetimes ;
1970+ self . is_collecting_anonymous_lifetimes = false ;
20041971
20051972 let lt = self
20061973 . with_anonymous_lifetime_mode ( AnonymousLifetimeMode :: ReportError , |this| {
@@ -2023,7 +1990,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20231990 let kind =
20241991 hir:: GenericParamKind :: Lifetime { kind : hir:: LifetimeParamKind :: Explicit } ;
20251992
2026- self . is_collecting_in_band_lifetimes = was_collecting_in_band;
1993+ self . is_collecting_anonymous_lifetimes = was_collecting_in_band;
20271994
20281995 ( param_name, kind)
20291996 }
@@ -2382,7 +2349,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
23822349 // Hence `impl Foo for &u32` becomes `impl<'f> Foo for &'f u32` for some fresh
23832350 // `'f`.
23842351 AnonymousLifetimeMode :: CreateParameter => {
2385- let fresh_name = self . collect_fresh_in_band_lifetime ( span) ;
2352+ let fresh_name = self . collect_fresh_anonymous_lifetime ( span) ;
23862353 hir:: Lifetime {
23872354 hir_id : self . next_id ( ) ,
23882355 span : self . lower_span ( span) ,
0 commit comments