Teach typeck/borrowck/solvers how to deal with async closures

This commit is contained in:
Michael Goulet
2024-01-24 22:27:25 +00:00
parent c567eddec2
commit a82bae2172
35 changed files with 1221 additions and 66 deletions

View File

@@ -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) };