Skip to content

Commit 6e23b38

Browse files
Skip collecting no-op DropGlue
Since 122662 this no longer gets used in vtables, so we're safe to fully drop generating these empty functions. Those are eventually cleaned up by LLVM, but it's wasteful to produce them in the first place.
1 parent 9822e3d commit 6e23b38

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -948,10 +948,14 @@ fn visit_instance_use<'tcx>(
948948
bug!("{:?} being reified", instance);
949949
}
950950
ty::InstanceKind::DropGlue(_, None) => {
951-
// Don't need to emit noop drop glue if we are calling directly.
952-
if !is_direct_call {
953-
output.push(create_fn_mono_item(tcx, instance, source));
954-
}
951+
// No-op drop glue never needs to be emitted.
952+
// In direct calls, we skip it in codegen. In indirect calls (vtables) we place a null
953+
// pointer rather than codegen'ing a pointer to the empty drop.
954+
//
955+
// Note that if user code casts drop_in_place to a fn(...) that's not a DropGlue, so
956+
// it won't hit this branch.
957+
//
958+
// If we get this wrong we'll see linker errors.
955959
}
956960
ty::InstanceKind::DropGlue(_, Some(_))
957961
| ty::InstanceKind::FutureDropPollShim(..)

0 commit comments

Comments
 (0)