Skip to content

Commit b4a689e

Browse files
committed
force share-generics on drop-glue locally
1 parent 81be7b8 commit b4a689e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,13 +1193,16 @@ impl<'v> RootCollector<'_, 'v> {
11931193
fn process_item(&mut self, id: hir::ItemId) {
11941194
match self.tcx.def_kind(id.owner_id) {
11951195
DefKind::Enum | DefKind::Struct | DefKind::Union => {
1196-
if self.mode == MonoItemCollectionMode::Eager
1197-
&& self.tcx.generics_of(id.owner_id).count() == 0
1198-
{
1199-
debug!("RootCollector: ADT drop-glue for `{id:?}`",);
1200-
1201-
let ty = self.tcx.type_of(id.owner_id.to_def_id()).no_bound_vars().unwrap();
1202-
visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
1196+
if self.tcx.generics_of(id.owner_id).count() == 0 {
1197+
let def_id = id.owner_id.to_def_id();
1198+
let force_share_drop_glue =
1199+
self.tcx.sess.opts.share_generics() && def_id.is_local();
1200+
if self.mode == MonoItemCollectionMode::Eager || force_share_drop_glue {
1201+
debug!("RootCollector: ADT drop-glue for `{id:?}`",);
1202+
1203+
let ty = self.tcx.type_of(def_id).no_bound_vars().unwrap();
1204+
visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
1205+
}
12031206
}
12041207
}
12051208
DefKind::GlobalAsm => {

0 commit comments

Comments
 (0)