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

@ -38,6 +38,7 @@ fn resolve_instance<'tcx>(
debug!(" => nontrivial drop glue");
match *ty.kind() {
ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..)
| ty::Tuple(..)
| ty::Adt(..)
@ -282,6 +283,16 @@ fn resolve_associated_item<'tcx>(
tcx.item_name(trait_item_id)
),
}
} else if tcx.async_fn_trait_kind_from_def_id(trait_ref.def_id).is_some() {
match *rcvr_args.type_at(0).kind() {
ty::CoroutineClosure(closure_def_id, args) => {
Some(Instance::new(closure_def_id, args))
}
_ => bug!(
"no built-in definition for `{trait_ref}::{}` for non-lending-closure type",
tcx.item_name(trait_item_id)
),
}
} else {
Instance::try_resolve_item_for_coroutine(tcx, trait_item_id, trait_id, rcvr_args)
}