@@ -13,6 +13,7 @@ use rustc_ast::*;
1313use rustc_data_structures:: stack:: ensure_sufficient_stack;
1414use rustc_hir as hir;
1515use rustc_hir:: def:: { DefKind , Res } ;
16+ use rustc_middle:: span_bug;
1617use rustc_session:: errors:: report_lit_error;
1718use rustc_span:: source_map:: { respan, Spanned } ;
1819use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -202,15 +203,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
202203 fn_decl_span,
203204 fn_arg_span,
204205 } ) => match coroutine_kind {
205- Some (
206- CoroutineKind :: Async { closure_id, .. }
207- | CoroutineKind :: Gen { closure_id, .. } ,
208- ) => self . lower_expr_async_closure (
206+ Some ( coroutine_kind) => self . lower_expr_coroutine_closure (
209207 binder,
210208 * capture_clause,
211209 e. id ,
212210 hir_id,
213- * closure_id ,
211+ * coroutine_kind ,
214212 fn_decl,
215213 body,
216214 * fn_decl_span,
@@ -1098,18 +1096,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
10981096 ( binder, params)
10991097 }
11001098
1101- fn lower_expr_async_closure (
1099+ fn lower_expr_coroutine_closure (
11021100 & mut self ,
11031101 binder : & ClosureBinder ,
11041102 capture_clause : CaptureBy ,
11051103 closure_id : NodeId ,
11061104 closure_hir_id : hir:: HirId ,
1107- inner_closure_id : NodeId ,
1105+ coroutine_kind : CoroutineKind ,
11081106 decl : & FnDecl ,
11091107 body : & Expr ,
11101108 fn_decl_span : Span ,
11111109 fn_arg_span : Span ,
11121110 ) -> hir:: ExprKind < ' hir > {
1111+ let CoroutineKind :: Async { closure_id : inner_closure_id, .. } = coroutine_kind else {
1112+ span_bug ! ( fn_decl_span, "`async gen` and `gen` closures are not supported, yet" ) ;
1113+ } ;
1114+
11131115 if let & ClosureBinder :: For { span, .. } = binder {
11141116 self . tcx . sess . emit_err ( NotSupportedForLifetimeBinderAsyncClosure { span } ) ;
11151117 }
0 commit comments