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:
parent
1dea922ea6
commit
24a24ec6ba
40 changed files with 1921 additions and 20 deletions
|
@ -22,6 +22,17 @@ fn is_unpin_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>)
|
|||
is_item_raw(tcx, query, LangItem::Unpin)
|
||||
}
|
||||
|
||||
fn has_surface_async_drop_raw<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::AsyncDrop)
|
||||
}
|
||||
|
||||
fn has_surface_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
||||
is_item_raw(tcx, query, LangItem::Drop)
|
||||
}
|
||||
|
||||
fn is_item_raw<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
|
@ -34,5 +45,13 @@ fn is_item_raw<'tcx>(
|
|||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
*providers = Providers { is_copy_raw, is_sized_raw, is_freeze_raw, is_unpin_raw, ..*providers };
|
||||
*providers = Providers {
|
||||
is_copy_raw,
|
||||
is_sized_raw,
|
||||
is_freeze_raw,
|
||||
is_unpin_raw,
|
||||
has_surface_async_drop_raw,
|
||||
has_surface_drop_raw,
|
||||
..*providers
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue