about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-01-14 17:55:26 +0000
committerbors <bors@rust-lang.org>2025-01-14 17:55:26 +0000
commit3736b85779d1db4c215b910004d7efcd7aff8408 (patch)
treed03e11c316bd316c8d73dcf80ea559bc4a29adac /compiler/rustc_monomorphize
parent8c39ce5b4fb5b61796e5fd8cec56c7b9abd2122b (diff)
parent27603b2739b3b3bc0c4f4278f402244704127c26 (diff)
Auto merge of #135313 - compiler-errors:needs-mono, r=BoxyUwU
Eagerly mono drop for structs with lifetimes

That is, use `!generics.requires_monomorphization()` rather than `generics.is_empty()` like the rest of the mono collector code.
Diffstat (limited to 'compiler/rustc_monomorphize')
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index c2e9498908c..0f3943cfe6a 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -1407,7 +1407,7 @@ impl<'v> RootCollector<'_, 'v> {
         match self.tcx.def_kind(id.owner_id) {
             DefKind::Enum | DefKind::Struct | DefKind::Union => {
                 if self.strategy == MonoItemCollectionStrategy::Eager
-                    && self.tcx.generics_of(id.owner_id).is_empty()
+                    && !self.tcx.generics_of(id.owner_id).requires_monomorphization(self.tcx)
                 {
                     debug!("RootCollector: ADT drop-glue for `{id:?}`",);
 
@@ -1420,7 +1420,10 @@ impl<'v> RootCollector<'_, 'v> {
                         return;
                     }
 
-                    let ty = self.tcx.type_of(id.owner_id.to_def_id()).no_bound_vars().unwrap();
+                    let ty = self.tcx.erase_regions(
+                        self.tcx.type_of(id.owner_id.to_def_id()).instantiate_identity(),
+                    );
+                    assert!(!ty.has_non_region_param());
                     visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
                 }
             }