Teach typeck/borrowck/solvers how to deal with async closures
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user