@@ -13,6 +13,7 @@ use rustc_ast::*;
13
13
use rustc_data_structures:: stack:: ensure_sufficient_stack;
14
14
use rustc_hir as hir;
15
15
use rustc_hir:: def:: { DefKind , Res } ;
16
+ use rustc_middle:: span_bug;
16
17
use rustc_session:: errors:: report_lit_error;
17
18
use rustc_span:: source_map:: { respan, Spanned } ;
18
19
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -202,15 +203,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
202
203
fn_decl_span,
203
204
fn_arg_span,
204
205
} ) => 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 (
209
207
binder,
210
208
* capture_clause,
211
209
e. id ,
212
210
hir_id,
213
- * closure_id ,
211
+ * coroutine_kind ,
214
212
fn_decl,
215
213
body,
216
214
* fn_decl_span,
@@ -1098,18 +1096,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
1098
1096
( binder, params)
1099
1097
}
1100
1098
1101
- fn lower_expr_async_closure (
1099
+ fn lower_expr_coroutine_closure (
1102
1100
& mut self ,
1103
1101
binder : & ClosureBinder ,
1104
1102
capture_clause : CaptureBy ,
1105
1103
closure_id : NodeId ,
1106
1104
closure_hir_id : hir:: HirId ,
1107
- inner_closure_id : NodeId ,
1105
+ coroutine_kind : CoroutineKind ,
1108
1106
decl : & FnDecl ,
1109
1107
body : & Expr ,
1110
1108
fn_decl_span : Span ,
1111
1109
fn_arg_span : Span ,
1112
1110
) -> 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
+
1113
1115
if let & ClosureBinder :: For { span, .. } = binder {
1114
1116
self . tcx . sess . emit_err ( NotSupportedForLifetimeBinderAsyncClosure { span } ) ;
1115
1117
}
0 commit comments