diff options
| author | Zachary S <zasample18+github@gmail.com> | 2025-08-23 20:48:44 -0500 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-09-08 14:26:08 -0700 |
| commit | 40c7fe39b6bd5f3cd05d9b7af699e826845558b3 (patch) | |
| tree | 2da5ca8fc0835d3ea79770d1b8a7de1d2fb4adaa /compiler/rustc_trait_selection/src/traits/vtable.rs | |
| parent | 6694a010befab52670db26ad17116d91bec43005 (diff) | |
| download | rust-40c7fe39b6bd5f3cd05d9b7af699e826845558b3.tar.gz rust-40c7fe39b6bd5f3cd05d9b7af699e826845558b3.zip | |
Only consider auto traits empty for the purposes of omitting vptrs from subtrait vtables
(cherry picked from commit 904e83c53fece4a34c2e90bb44e362d8868d65f3)
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/vtable.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/vtable.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 3565c11249a..7e8a41457d4 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -153,7 +153,12 @@ fn prepare_vtable_segments_inner<'tcx, T>( // emit innermost item, move to next sibling and stop there if possible, otherwise jump to outer level. while let Some((inner_most_trait_ref, emit_vptr, mut siblings)) = stack.pop() { - let has_entries = has_own_existential_vtable_entries(tcx, inner_most_trait_ref.def_id); + // We don't need to emit a vptr for "truly-empty" supertraits, but we *do* need to emit a + // vptr for supertraits that have no methods, but that themselves have supertraits + // with methods, so we check if any transitive supertrait has entries here (this includes + // the trait itself). + let has_entries = ty::elaborate::supertrait_def_ids(tcx, inner_most_trait_ref.def_id) + .any(|def_id| has_own_existential_vtable_entries(tcx, def_id)); segment_visitor(VtblSegment::TraitOwnEntries { trait_ref: inner_most_trait_ref, |
