@@ -314,7 +314,9 @@ impl<'tcx> InstanceKind<'tcx> {
314314 if self . requires_inline ( tcx) {
315315 return true ;
316316 }
317- if let ty:: InstanceKind :: DropGlue ( .., Some ( ty) ) = * self {
317+ if let ty:: InstanceKind :: DropGlue ( .., Some ( ty) )
318+ | ty:: InstanceKind :: AsyncDropGlueCtorShim ( .., Some ( ty) ) = * self
319+ {
318320 // Drop glue generally wants to be instantiated at every codegen
319321 // unit, but without an #[inline] hint. We should make this
320322 // available to normal end-users.
@@ -329,29 +331,14 @@ impl<'tcx> InstanceKind<'tcx> {
329331 // drops of `Option::None` before LTO. We also respect the intent of
330332 // `#[inline]` on `Drop::drop` implementations.
331333 return ty. ty_adt_def ( ) . map_or ( true , |adt_def| {
332- adt_def
333- . destructor ( tcx)
334- . map_or_else ( || adt_def. is_enum ( ) , |dtor| tcx. cross_crate_inlinable ( dtor. did ) )
335- } ) ;
336- }
337- if let ty:: InstanceKind :: AsyncDropGlueCtorShim ( .., Some ( ty) ) = * self {
338- // Async drop glue generally wants to be instantiated at
339- // every codegen unit, but without an #[inline] hint. We
340- // should make this available to normal end-users.
341- if tcx. sess . opts . incremental . is_none ( ) {
342- return true ;
343- }
344- // When compiling with incremental, we can generate a *lot* of
345- // codegen units. Including drop glue into all of them has a
346- // considerable compile time cost.
347- //
348- // We include enums without destructors to allow, say, optimizing
349- // drops of `Option::None` before LTO. We also respect the intent of
350- // `#[inline]` on `Drop::drop` implementations.
351- return ty. ty_adt_def ( ) . map_or ( true , |adt_def| {
352- adt_def
353- . async_destructor ( tcx)
354- . map_or_else ( || adt_def. is_enum ( ) , |dtor| tcx. cross_crate_inlinable ( dtor. ctor ) )
334+ match * self {
335+ ty:: InstanceKind :: DropGlue ( ..) => adt_def. destructor ( tcx) . map ( |dtor| dtor. did ) ,
336+ ty:: InstanceKind :: AsyncDropGlueCtorShim ( ..) => {
337+ adt_def. async_destructor ( tcx) . map ( |dtor| dtor. ctor )
338+ }
339+ _ => unreachable ! ( ) ,
340+ }
341+ . map_or_else ( || adt_def. is_enum ( ) , |did| tcx. cross_crate_inlinable ( did) )
355342 } ) ;
356343 }
357344 if let ty:: InstanceKind :: ThreadLocalShim ( ..) = * self {
0 commit comments