Optimize async drop glue for some old types
This commit is contained in:
parent
a47173c4f7
commit
7cdd95e1a6
11 changed files with 161 additions and 89 deletions
|
@ -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(..)
|
||||
|
|
|
@ -36,7 +36,7 @@ fn needs_async_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty
|
|||
// it needs async drop.
|
||||
let adt_has_async_dtor =
|
||||
|adt_def: ty::AdtDef<'tcx>| adt_def.async_destructor(tcx).map(|_| DtorType::Significant);
|
||||
let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_dtor, false)
|
||||
let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_async_dtor, false)
|
||||
.filter(filter_array_elements(tcx, query.param_env))
|
||||
.next()
|
||||
.is_some();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue