about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-01-24 22:27:25 +0000
committerMichael Goulet <michael@errs.io>2024-02-06 02:22:58 +0000
commita82bae2172499864c12a1d0b412931ad884911f7 (patch)
treec7299fdfd83be3818fcffdb86639146c9d29bb69 /compiler/rustc_ast_lowering/src/expr.rs
parentc567eddec2c628d4f13707866731e1b2013ad236 (diff)
downloadrust-a82bae2172499864c12a1d0b412931ad884911f7.tar.gz
rust-a82bae2172499864c12a1d0b412931ad884911f7.zip
Teach typeck/borrowck/solvers how to deal with async closures
Diffstat (limited to 'compiler/rustc_ast_lowering/src/expr.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 2241b4cd8e5..9990d526bf7 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -1,3 +1,5 @@
+use std::assert_matches::assert_matches;
+
 use super::errors::{
     AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot,
     ClosureCannotBeStatic, CoroutineTooManyParameters,
@@ -1027,6 +1029,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
     ) -> hir::ExprKind<'hir> {
         let (binder_clause, generic_params) = self.lower_closure_binder(binder);
 
+        assert_matches!(
+            coroutine_kind,
+            CoroutineKind::Async { .. },
+            "only async closures are supported currently"
+        );
+
         let body = self.with_new_scopes(fn_decl_span, |this| {
             let inner_decl =
                 FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };