Make async drop code more consistent with regular drop code
Fixes #126573
This commit is contained in:
parent
f873ae029e
commit
af10880f6b
4 changed files with 67 additions and 14 deletions
|
@ -371,7 +371,7 @@ fn exported_symbols_provider_local(
|
|||
}) => {
|
||||
// A little sanity-check
|
||||
debug_assert_eq!(
|
||||
args.non_erasable_generics(tcx, def_id).skip(1).next(),
|
||||
args.non_erasable_generics(tcx, def_id).next(),
|
||||
Some(GenericArgKind::Type(ty))
|
||||
);
|
||||
symbols.push((
|
||||
|
@ -422,10 +422,7 @@ fn upstream_monomorphizations_provider(
|
|||
}
|
||||
ExportedSymbol::AsyncDropGlueCtorShim(ty) => {
|
||||
if let Some(async_drop_in_place_fn_def_id) = async_drop_in_place_fn_def_id {
|
||||
(
|
||||
async_drop_in_place_fn_def_id,
|
||||
tcx.mk_args(&[tcx.lifetimes.re_erased.into(), ty.into()]),
|
||||
)
|
||||
(async_drop_in_place_fn_def_id, tcx.mk_args(&[ty.into()]))
|
||||
} else {
|
||||
// `drop_in_place` in place does not exist, don't try
|
||||
// to use it.
|
||||
|
@ -480,6 +477,17 @@ fn upstream_drop_glue_for_provider<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
fn upstream_async_drop_glue_for_provider<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
) -> Option<CrateNum> {
|
||||
if let Some(def_id) = tcx.lang_items().async_drop_in_place_fn() {
|
||||
tcx.upstream_monomorphizations_for(def_id).and_then(|monos| monos.get(&args).cloned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||
!tcx.reachable_set(()).contains(&def_id)
|
||||
}
|
||||
|
@ -491,6 +499,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
providers.upstream_monomorphizations = upstream_monomorphizations_provider;
|
||||
providers.is_unreachable_local_definition = is_unreachable_local_definition_provider;
|
||||
providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
|
||||
providers.upstream_async_drop_glue_for = upstream_async_drop_glue_for_provider;
|
||||
providers.wasm_import_module_map = wasm_import_module_map;
|
||||
providers.extern_queries.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
|
||||
providers.extern_queries.upstream_monomorphizations_for =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue