Bug
When resolving async_drop_in_place (LangItem::AsyncDropInPlace), nontrivial async drop glue requires the type kind to be in an allowlist. That list includes Closure, CoroutineClosure, Coroutine, Tuple, Adt, Dynamic, Array, and Slice, but not UnsafeBinder or ty::Pat.
Sync DropGlue resolution for the same structural cases does allow UnsafeBinder (and still omits Pat).
So for an UnsafeBinder type with needs_async_drop == true, instance resolution returns Ok(None) instead of building AsyncDropGlueCtor, while sync drop glue would accept the binder.
needs_drop_components / async drop component logic treats UnsafeBinder as a component type (Ok(smallvec![ty])) and peels Pat to its inner type, so the allowlist is inconsistent with the needs-drop decomposition.
Affected code
compiler/rustc_ty_utils/src/instance.rs (resolve_instance_raw, AsyncDropInPlace branch)
Impact
Wrong/missing async-drop instance for unsafe-binder types that need async drop (I-wrong), vs sync drop. Unstable async_drop / unsafe_binder interaction.
ty::Pat note (latent): Pattern types currently focus on integer ranges (Copy, typically no drop). When Pat can wrap drop-bearing inners, both DropGlue and AsyncDropGlueCtor omit Pat from the nontrivial allowlist while needs_drop can be true via peeled components. Prefer adding Pat alongside UnsafeBinder for consistency with Array/Slice compound handling, or document intentional deferral.
Origin
| Lines |
Commit |
Date |
Author |
| AsyncDropInPlace allowlist |
80c0b7e90fd0 / async-drop shim work |
2024-04-17 |
Daria Sukhonina |
| UnsafeBinder added to DropGlue only |
later UnsafeBinder wiring |
|
|
Suggested fix
Add | ty::UnsafeBinder(..) to the AsyncDropGlueCtor nontrivial match (mirror DropGlue). Optionally add | ty::Pat(..) to both DropGlue and AsyncDropGlueCtor allowlists for consistency with component peeling.
Related
Bug
When resolving
async_drop_in_place(LangItem::AsyncDropInPlace), nontrivial async drop glue requires the type kind to be in an allowlist. That list includesClosure,CoroutineClosure,Coroutine,Tuple,Adt,Dynamic,Array, andSlice, but notUnsafeBinderorty::Pat.Sync DropGlue resolution for the same structural cases does allow
UnsafeBinder(and still omitsPat).So for an
UnsafeBindertype withneeds_async_drop == true, instance resolution returnsOk(None)instead of buildingAsyncDropGlueCtor, while sync drop glue would accept the binder.needs_drop_components/ async drop component logic treatsUnsafeBinderas a component type (Ok(smallvec![ty])) and peelsPatto its inner type, so the allowlist is inconsistent with the needs-drop decomposition.Affected code
compiler/rustc_ty_utils/src/instance.rs(resolve_instance_raw,AsyncDropInPlacebranch)Impact
Wrong/missing async-drop instance for unsafe-binder types that need async drop (
I-wrong), vs sync drop. Unstableasync_drop/unsafe_binderinteraction.ty::Patnote (latent): Pattern types currently focus on integer ranges (Copy, typically no drop). When Pat can wrap drop-bearing inners, both DropGlue and AsyncDropGlueCtor omitPatfrom the nontrivial allowlist whileneeds_dropcan be true via peeled components. Prefer addingPatalongsideUnsafeBinderfor consistency withArray/Slicecompound handling, or document intentional deferral.Origin
80c0b7e90fd0/ async-drop shim workSuggested fix
Add
| ty::UnsafeBinder(..)to the AsyncDropGlueCtor nontrivial match (mirror DropGlue). Optionally add| ty::Pat(..)to both DropGlue and AsyncDropGlueCtor allowlists for consistency with component peeling.Related
UnsafeBinderin the same file