@@ -805,7 +805,12 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
805
805
sig. decl . has_self ( ) ,
806
806
sig. decl . inputs . iter ( ) . map ( |Param { ty, .. } | ( None , & * * ty) ) ,
807
807
& sig. decl . output ,
808
- )
808
+ ) ;
809
+
810
+ this. record_lifetime_params_for_async (
811
+ fn_id,
812
+ sig. header . asyncness . opt_return_id ( ) ,
813
+ ) ;
809
814
} ,
810
815
) ;
811
816
return ;
@@ -847,41 +852,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
847
852
} ,
848
853
) ;
849
854
850
- // Construct the list of in-scope lifetime parameters for async lowering.
851
- // We include all lifetime parameters, either named or "Fresh".
852
- // The order of those parameters does not matter, as long as it is
853
- // deterministic.
854
- if let Some ( ( async_node_id, _) ) = async_node_id {
855
- let mut extra_lifetime_params = this
856
- . r
857
- . extra_lifetime_params_map
858
- . get ( & fn_id)
859
- . cloned ( )
860
- . unwrap_or_default ( ) ;
861
- for rib in this. lifetime_ribs . iter ( ) . rev ( ) {
862
- extra_lifetime_params. extend (
863
- rib. bindings
864
- . iter ( )
865
- . map ( |( & ident, & ( node_id, res) ) | ( ident, node_id, res) ) ,
866
- ) ;
867
- match rib. kind {
868
- LifetimeRibKind :: Item => break ,
869
- LifetimeRibKind :: AnonymousCreateParameter {
870
- binder, ..
871
- } => {
872
- if let Some ( earlier_fresh) =
873
- this. r . extra_lifetime_params_map . get ( & binder)
874
- {
875
- extra_lifetime_params. extend ( earlier_fresh) ;
876
- }
877
- }
878
- _ => { }
879
- }
880
- }
881
- this. r
882
- . extra_lifetime_params_map
883
- . insert ( async_node_id, extra_lifetime_params) ;
884
- }
855
+ this. record_lifetime_params_for_async ( fn_id, async_node_id) ;
885
856
886
857
if let Some ( body) = body {
887
858
// Ignore errors in function bodies if this is rustdoc
@@ -3926,6 +3897,36 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
3926
3897
Some ( ( ident. name , ns) ) ,
3927
3898
)
3928
3899
}
3900
+
3901
+ /// Construct the list of in-scope lifetime parameters for async lowering.
3902
+ /// We include all lifetime parameters, either named or "Fresh".
3903
+ /// The order of those parameters does not matter, as long as it is
3904
+ /// deterministic.
3905
+ fn record_lifetime_params_for_async (
3906
+ & mut self ,
3907
+ fn_id : NodeId ,
3908
+ async_node_id : Option < ( NodeId , Span ) > ,
3909
+ ) {
3910
+ if let Some ( ( async_node_id, _) ) = async_node_id {
3911
+ let mut extra_lifetime_params =
3912
+ self . r . extra_lifetime_params_map . get ( & fn_id) . cloned ( ) . unwrap_or_default ( ) ;
3913
+ for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
3914
+ extra_lifetime_params. extend (
3915
+ rib. bindings . iter ( ) . map ( |( & ident, & ( node_id, res) ) | ( ident, node_id, res) ) ,
3916
+ ) ;
3917
+ match rib. kind {
3918
+ LifetimeRibKind :: Item => break ,
3919
+ LifetimeRibKind :: AnonymousCreateParameter { binder, .. } => {
3920
+ if let Some ( earlier_fresh) = self . r . extra_lifetime_params_map . get ( & binder) {
3921
+ extra_lifetime_params. extend ( earlier_fresh) ;
3922
+ }
3923
+ }
3924
+ _ => { }
3925
+ }
3926
+ }
3927
+ self . r . extra_lifetime_params_map . insert ( async_node_id, extra_lifetime_params) ;
3928
+ }
3929
+ }
3929
3930
}
3930
3931
3931
3932
struct LifetimeCountVisitor < ' a , ' b > {
0 commit comments