@@ -904,9 +904,12 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
904
904
sig. decl . inputs . iter ( ) . map ( |Param { ty, .. } | ( None , & * * ty) ) ,
905
905
& sig. decl . output ,
906
906
) ;
907
+
908
+ if let Some ( ( async_node_id, span) ) = sig. header . asyncness . opt_return_id ( ) {
909
+ this. record_lifetime_params_for_impl_trait ( async_node_id, span) ;
910
+ }
907
911
} ,
908
912
) ;
909
- self . record_lifetime_params_for_async ( fn_id, sig. header . asyncness . opt_return_id ( ) ) ;
910
913
return ;
911
914
}
912
915
FnKind :: Fn ( ..) => {
@@ -942,12 +945,14 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
942
945
. iter ( )
943
946
. map ( |Param { pat, ty, .. } | ( Some ( & * * pat) , & * * ty) ) ,
944
947
& declaration. output ,
945
- )
948
+ ) ;
949
+
950
+ if let Some ( ( async_node_id, span) ) = async_node_id {
951
+ this. record_lifetime_params_for_impl_trait ( async_node_id, span) ;
952
+ }
946
953
} ,
947
954
) ;
948
955
949
- this. record_lifetime_params_for_async ( fn_id, async_node_id) ;
950
-
951
956
if let Some ( body) = body {
952
957
// Ignore errors in function bodies if this is rustdoc
953
958
// Be sure not to set this until the function signature has been resolved.
@@ -4326,39 +4331,32 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
4326
4331
)
4327
4332
}
4328
4333
4329
- /// Construct the list of in-scope lifetime parameters for async lowering.
4334
+ /// Construct the list of in-scope lifetime parameters for impl trait lowering.
4330
4335
/// We include all lifetime parameters, either named or "Fresh".
4331
4336
/// The order of those parameters does not matter, as long as it is
4332
4337
/// deterministic.
4333
- fn record_lifetime_params_for_async (
4334
- & mut self ,
4335
- fn_id : NodeId ,
4336
- async_node_id : Option < ( NodeId , Span ) > ,
4337
- ) {
4338
- if let Some ( ( async_node_id, span) ) = async_node_id {
4339
- let mut extra_lifetime_params =
4340
- self . r . extra_lifetime_params_map . get ( & fn_id) . cloned ( ) . unwrap_or_default ( ) ;
4341
- for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
4342
- extra_lifetime_params. extend (
4343
- rib. bindings . iter ( ) . map ( |( & ident, & ( node_id, res) ) | ( ident, node_id, res) ) ,
4344
- ) ;
4345
- match rib. kind {
4346
- LifetimeRibKind :: Item => break ,
4347
- LifetimeRibKind :: AnonymousCreateParameter { binder, .. } => {
4348
- if let Some ( earlier_fresh) = self . r . extra_lifetime_params_map . get ( & binder) {
4349
- extra_lifetime_params. extend ( earlier_fresh) ;
4350
- }
4351
- }
4352
- LifetimeRibKind :: Generics { .. } => { }
4353
- _ => {
4354
- // We are in a function definition. We should only find `Generics`
4355
- // and `AnonymousCreateParameter` inside the innermost `Item`.
4356
- span_bug ! ( span, "unexpected rib kind: {:?}" , rib. kind)
4338
+ fn record_lifetime_params_for_impl_trait ( & mut self , impl_trait_node_id : NodeId , span : Span ) {
4339
+ let mut extra_lifetime_params = vec ! [ ] ;
4340
+
4341
+ for rib in self . lifetime_ribs . iter ( ) . rev ( ) {
4342
+ extra_lifetime_params
4343
+ . extend ( rib. bindings . iter ( ) . map ( |( & ident, & ( node_id, res) ) | ( ident, node_id, res) ) ) ;
4344
+ match rib. kind {
4345
+ LifetimeRibKind :: Item => break ,
4346
+ LifetimeRibKind :: AnonymousCreateParameter { binder, .. } => {
4347
+ if let Some ( earlier_fresh) = self . r . extra_lifetime_params_map . get ( & binder) {
4348
+ extra_lifetime_params. extend ( earlier_fresh) ;
4357
4349
}
4358
4350
}
4351
+ LifetimeRibKind :: Generics { .. } => { }
4352
+ _ => {
4353
+ // We are in a function definition. We should only find `Generics`
4354
+ // and `AnonymousCreateParameter` inside the innermost `Item`.
4355
+ span_bug ! ( span, "unexpected rib kind: {:?}" , rib. kind)
4356
+ }
4359
4357
}
4360
- self . r . extra_lifetime_params_map . insert ( async_node_id, extra_lifetime_params) ;
4361
4358
}
4359
+ self . r . extra_lifetime_params_map . insert ( impl_trait_node_id, extra_lifetime_params) ;
4362
4360
}
4363
4361
4364
4362
fn resolve_and_cache_rustdoc_path ( & mut self , path_str : & str , ns : Namespace ) -> Option < Res > {
0 commit comments