Add simple async drop glue generation

Explainer: https://zetanumbers.github.io/book/async-drop-design.html

https://github.com/rust-lang/rust/pull/121801
This commit is contained in:
zetanumbers 2024-02-13 12:31:41 +03:00 committed by Daria Sukhonina
parent 1dea922ea6
commit 24a24ec6ba
40 changed files with 1921 additions and 20 deletions

View file

@ -54,6 +54,47 @@ fn resolve_instance<'tcx>(
debug!(" => trivial drop glue");
ty::InstanceDef::DropGlue(def_id, None)
}
} else if Some(def_id) == tcx.lang_items().async_drop_in_place_fn() {
let ty = args.type_at(0);
match *ty.kind() {
ty::Array(..)
| ty::Slice(_)
| ty::Tuple(_)
| ty::Bool
| ty::Char
| ty::Int(_)
| ty::Uint(_)
| ty::Float(_)
| ty::Str
| ty::RawPtr(_, _)
| ty::Ref(..)
| ty::FnDef(..)
| ty::FnPtr(..)
| ty::Infer(ty::IntVar(_) | ty::FloatVar(_))
| ty::Adt(..)
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::CoroutineWitness(..)
| ty::Pat(..)
| ty::Never
| ty::Coroutine(..) => {}
ty::Param(_)
| ty::Error(_)
| ty::Dynamic(..)
| ty::Alias(..)
| ty::Infer(ty::TyVar(_))
| ty::Bound(..)
| ty::Foreign(_)
| ty::Placeholder(_)
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
return Ok(None);
}
}
debug!(" => async drop glue ctor");
ty::InstanceDef::AsyncDropGlueCtorShim(def_id, ty)
} else {
debug!(" => free item");
// FIXME(effects): we may want to erase the effect param if that is present on this item.