@@ -199,6 +199,9 @@ enum LifetimeRibKind {
199
199
/// before said generic parameter. Also see the `visit_generics` override.
200
200
ForwardGenericParamBan ,
201
201
202
+ /// We passed through a function definition. Disallow in-band definitions.
203
+ FnBody ,
204
+
202
205
/// For **Modern** cases, create a new anonymous region parameter
203
206
/// and reference that.
204
207
///
@@ -740,10 +743,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
740
743
let previous_state = replace ( & mut this. in_func_body , true ) ;
741
744
// Resolve the function body, potentially inside the body of an async closure
742
745
this. with_lifetime_rib ( LifetimeRibKind :: AnonymousPassThrough ( fn_id) , |this| {
743
- match fn_kind {
746
+ this . with_lifetime_rib ( LifetimeRibKind :: FnBody , |this| match fn_kind {
744
747
FnKind :: Fn ( .., body) => walk_list ! ( this, visit_block, body) ,
745
748
FnKind :: Closure ( _, body) => this. visit_expr ( body) ,
746
- }
749
+ } )
747
750
} ) ;
748
751
749
752
debug ! ( "(resolving function) leaving function" ) ;
@@ -1153,6 +1156,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1153
1156
// point.
1154
1157
in_band_rib_index. get_or_insert ( ( i, ident. span ) ) ;
1155
1158
}
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
+ }
1156
1163
_ => { }
1157
1164
}
1158
1165
}
0 commit comments