about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/instance.rs
diff options
context:
space:
mode:
authorzetanumbers <dariasukhonina@gmail.com>2024-02-13 12:31:41 +0300
committerDaria Sukhonina <dariasukhonina@gmail.com>2024-04-16 20:45:07 +0300
commit24a24ec6ba24bfe5e0980d22f585c98a608ec701 (patch)
tree0f0eeced9b28d8c0cef3325886775aa27607dd67 /compiler/rustc_ty_utils/src/instance.rs
parent1dea922ea6e74f99a0e97de5cdb8174e4dea0444 (diff)
downloadrust-24a24ec6ba24bfe5e0980d22f585c98a608ec701.tar.gz
rust-24a24ec6ba24bfe5e0980d22f585c98a608ec701.zip
Add simple async drop glue generation
Explainer: https://zetanumbers.github.io/book/async-drop-design.html

https://github.com/rust-lang/rust/pull/121801
Diffstat (limited to 'compiler/rustc_ty_utils/src/instance.rs')
-rw-r--r--compiler/rustc_ty_utils/src/instance.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index a8f9afb87dd..3a18f4d0939 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -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.