diff options
| author | bors <bors@rust-lang.org> | 2024-05-31 10:12:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-31 10:12:24 +0000 |
| commit | 99cb42c29641aee2cce6521e07960d4de93205c8 (patch) | |
| tree | dcffa6a4fe3c9f4a8ca6ad9989ce73afd7516dbd /compiler/rustc_ty_utils/src/instance.rs | |
| parent | bf8fff783ff533c055d276378ada30563312def1 (diff) | |
| parent | 4903cf4df6f6647177f1645ab17ebab933564949 (diff) | |
Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk
Implement `needs_async_drop` in rustc and optimize async drop glue This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948. Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
Diffstat (limited to 'compiler/rustc_ty_utils/src/instance.rs')
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 0d089205c1e..e4dcea785d4 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -4,6 +4,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::traits::{BuiltinImplSource, CodegenObligationError}; +use rustc_middle::ty::util::AsyncDropGlueMorphology; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt}; use rustc_span::sym; @@ -59,7 +60,7 @@ fn resolve_instance<'tcx>( } else if Some(def_id) == tcx.lang_items().async_drop_in_place_fn() { let ty = args.type_at(0); - if !ty.is_async_destructor_noop(tcx, param_env) { + if ty.async_drop_glue_morphology(tcx) != AsyncDropGlueMorphology::Noop { match *ty.kind() { ty::Closure(..) | ty::CoroutineClosure(..) |
