Apply suggestions from oli-obk's review
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
This commit is contained in:
parent
af10880f6b
commit
1a8eae1aba
2 changed files with 15 additions and 34 deletions
|
@ -314,7 +314,9 @@ impl<'tcx> InstanceKind<'tcx> {
|
|||
if self.requires_inline(tcx) {
|
||||
return true;
|
||||
}
|
||||
if let ty::InstanceKind::DropGlue(.., Some(ty)) = *self {
|
||||
if let ty::InstanceKind::DropGlue(.., Some(ty))
|
||||
| ty::InstanceKind::AsyncDropGlueCtorShim(.., Some(ty)) = *self
|
||||
{
|
||||
// Drop glue generally wants to be instantiated at every codegen
|
||||
// unit, but without an #[inline] hint. We should make this
|
||||
// available to normal end-users.
|
||||
|
@ -329,29 +331,14 @@ impl<'tcx> InstanceKind<'tcx> {
|
|||
// drops of `Option::None` before LTO. We also respect the intent of
|
||||
// `#[inline]` on `Drop::drop` implementations.
|
||||
return ty.ty_adt_def().map_or(true, |adt_def| {
|
||||
adt_def
|
||||
.destructor(tcx)
|
||||
.map_or_else(|| adt_def.is_enum(), |dtor| tcx.cross_crate_inlinable(dtor.did))
|
||||
});
|
||||
}
|
||||
if let ty::InstanceKind::AsyncDropGlueCtorShim(.., Some(ty)) = *self {
|
||||
// Async drop glue generally wants to be instantiated at
|
||||
// every codegen unit, but without an #[inline] hint. We
|
||||
// should make this available to normal end-users.
|
||||
if tcx.sess.opts.incremental.is_none() {
|
||||
return true;
|
||||
}
|
||||
// When compiling with incremental, we can generate a *lot* of
|
||||
// codegen units. Including drop glue into all of them has a
|
||||
// considerable compile time cost.
|
||||
//
|
||||
// We include enums without destructors to allow, say, optimizing
|
||||
// drops of `Option::None` before LTO. We also respect the intent of
|
||||
// `#[inline]` on `Drop::drop` implementations.
|
||||
return ty.ty_adt_def().map_or(true, |adt_def| {
|
||||
adt_def
|
||||
.async_destructor(tcx)
|
||||
.map_or_else(|| adt_def.is_enum(), |dtor| tcx.cross_crate_inlinable(dtor.ctor))
|
||||
match *self {
|
||||
ty::InstanceKind::DropGlue(..) => adt_def.destructor(tcx).map(|dtor| dtor.did),
|
||||
ty::InstanceKind::AsyncDropGlueCtorShim(..) => {
|
||||
adt_def.async_destructor(tcx).map(|dtor| dtor.ctor)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
.map_or_else(|| adt_def.is_enum(), |did| tcx.cross_crate_inlinable(did))
|
||||
});
|
||||
}
|
||||
if let ty::InstanceKind::ThreadLocalShim(..) = *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue