@@ -789,8 +789,9 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
789
789
let previous_value = self . diagnostic_metadata . current_function ;
790
790
match fn_kind {
791
791
// Bail if the function is foreign, and thus cannot validly have
792
- // a body.
793
- FnKind :: Fn ( FnCtxt :: Foreign , _, sig, _, generics, _) => {
792
+ // a body, or if there's no body for some other reason.
793
+ FnKind :: Fn ( FnCtxt :: Foreign , _, sig, _, generics, _)
794
+ | FnKind :: Fn ( _, _, sig, _, generics, None ) => {
794
795
self . visit_fn_header ( & sig. header ) ;
795
796
self . visit_generics ( generics) ;
796
797
self . with_lifetime_rib (
@@ -804,7 +805,12 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
804
805
sig. decl . has_self ( ) ,
805
806
sig. decl . inputs . iter ( ) . map ( |Param { ty, .. } | ( None , & * * ty) ) ,
806
807
& sig. decl . output ,
807
- )
808
+ ) ;
809
+
810
+ this. record_lifetime_params_for_async (
811
+ fn_id,
812
+ sig. header . asyncness . opt_return_id ( ) ,
813
+ ) ;
808
814
} ,
809
815
) ;
810
816
return ;
@@ -846,41 +852,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
846
852
} ,
847
853
) ;
848
854
849
- // Construct the list of in-scope lifetime parameters for async lowering.
850
- // We include all lifetime parameters, either named or "Fresh".
851
- // The order of those parameters does not matter, as long as it is
852
- // deterministic.
853
- if let Some ( ( async_node_id, _) ) = async_node_id {
854
- let mut extra_lifetime_params = this
855
- . r
856
- . extra_lifetime_params_map
857
- . get ( & fn_id)
858
- . cloned ( )
859
- . unwrap_or_default ( ) ;
860
- for rib in this. lifetime_ribs . iter ( ) . rev ( ) {
861
- extra_lifetime_params. extend (
862
- rib. bindings
863
- . iter ( )
864
- . map ( |( & ident, & ( node_id, res) ) | ( ident, node_id, res) ) ,
865
- ) ;
866
- match rib. kind {
867
- LifetimeRibKind :: Item => break ,
868
- LifetimeRibKind :: AnonymousCreateParameter {
869
- binder, ..
870
- } => {
871
- if let Some ( earlier_fresh) =
872
- this. r . extra_lifetime_params_map . get ( & binder)
873
- {
874
- extra_lifetime_params. extend ( earlier_fresh) ;
875
- }
876
- }
877
- _ => { }
878
- }
879
- }
880
- this. r
881
- . extra_lifetime_params_map
882
- . insert ( async_node_id, extra_lifetime_params) ;
883
- }
855
+ this. record_lifetime_params_for_async ( fn_id, async_node_id) ;
884
856
885
857
if let Some ( body) = body {
886
858
// Ignore errors in function bodies if this is rustdoc
@@ -3925,6 +3897,36 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
3925
3897
Some ( ( ident. name , ns) ) ,
3926
3898
)
3927
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
+ }
3928
3930
}
3929
3931
3930
3932
struct LifetimeCountVisitor < ' a , ' b > {
0 commit comments