1
Fork 0

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

@ -822,6 +822,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let upvar_args = match closure_ty.kind() {
ty::Closure(_, args) => ty::UpvarArgs::Closure(args),
ty::Coroutine(_, args) => ty::UpvarArgs::Coroutine(args),
ty::CoroutineClosure(_, args) => ty::UpvarArgs::CoroutineClosure(args),
_ => return,
};

View file

@ -556,6 +556,9 @@ impl<'tcx> Cx<'tcx> {
ty::Coroutine(def_id, args) => {
(def_id, UpvarArgs::Coroutine(args), Some(tcx.coroutine_movability(def_id)))
}
ty::CoroutineClosure(def_id, args) => {
(def_id, UpvarArgs::CoroutineClosure(args), None)
}
_ => {
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
}

View file

@ -127,10 +127,24 @@ impl<'tcx> Cx<'tcx> {
ty::Coroutine(..) => {
Param { ty: closure_ty, pat: None, ty_span: None, self_kind: None, hir_id: None }
}
ty::Closure(_, closure_args) => {
ty::Closure(_, args) => {
let closure_env_ty = self.tcx.closure_env_ty(
closure_ty,
closure_args.as_closure().kind(),
args.as_closure().kind(),
self.tcx.lifetimes.re_erased,
);
Param {
ty: closure_env_ty,
pat: None,
ty_span: None,
self_kind: None,
hir_id: None,
}
}
ty::CoroutineClosure(_, args) => {
let closure_env_ty = self.tcx.closure_env_ty(
closure_ty,
args.as_coroutine_closure().kind(),
self.tcx.lifetimes.re_erased,
);
Param {