@@ -199,6 +199,9 @@ enum LifetimeRibKind {
199199 /// before said generic parameter. Also see the `visit_generics` override.
200200 ForwardGenericParamBan ,
201201
202+ /// We passed through a function definition. Disallow in-band definitions.
203+ FnBody ,
204+
202205 /// For **Modern** cases, create a new anonymous region parameter
203206 /// and reference that.
204207 ///
@@ -740,10 +743,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
740743 let previous_state = replace ( & mut this. in_func_body , true ) ;
741744 // Resolve the function body, potentially inside the body of an async closure
742745 this. with_lifetime_rib ( LifetimeRibKind :: AnonymousPassThrough ( fn_id) , |this| {
743- match fn_kind {
746+ this . with_lifetime_rib ( LifetimeRibKind :: FnBody , |this| match fn_kind {
744747 FnKind :: Fn ( .., body) => walk_list ! ( this, visit_block, body) ,
745748 FnKind :: Closure ( _, body) => this. visit_expr ( body) ,
746- }
749+ } )
747750 } ) ;
748751
749752 debug ! ( "(resolving function) leaving function" ) ;
@@ -1153,6 +1156,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
11531156 // point.
11541157 in_band_rib_index. get_or_insert ( ( i, ident. span ) ) ;
11551158 }
1159+ LifetimeRibKind :: FnBody => {
1160+ // Hijack `in_band_rib_index` to ensure we do not crate an in-band definition.
1161+ in_band_rib_index. get_or_insert ( ( i, ident. span ) ) ;
1162+ }
11561163 _ => { }
11571164 }
11581165 }
0 commit comments