about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/common_traits.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/common_traits.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/common_traits.rs')
-rw-r--r--compiler/rustc_ty_utils/src/common_traits.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc_ty_utils/src/common_traits.rs b/compiler/rustc_ty_utils/src/common_traits.rs
index 51b908881eb..cb95239e991 100644
--- a/compiler/rustc_ty_utils/src/common_traits.rs
+++ b/compiler/rustc_ty_utils/src/common_traits.rs
@@ -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
+    };
 }