Never emit vptr
for empty/auto traits
This commit is contained in:
parent
88f311479d
commit
781bff0499
4 changed files with 36 additions and 14 deletions
|
@ -154,18 +154,17 @@ 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());
|
||||
|
||||
segment_visitor(VtblSegment::TraitOwnEntries {
|
||||
trait_ref: inner_most_trait_ref,
|
||||
emit_vptr: emit_vptr && !tcx.sess.opts.unstable_opts.no_trait_vptr,
|
||||
emit_vptr: emit_vptr && has_entries && !tcx.sess.opts.unstable_opts.no_trait_vptr,
|
||||
})?;
|
||||
|
||||
// If we've emitted (fed to `segment_visitor`) a trait that has methods present in the vtable,
|
||||
// we'll need to emit vptrs from now on.
|
||||
if !emit_vptr_on_new_entry
|
||||
&& has_own_existential_vtable_entries(tcx, inner_most_trait_ref.def_id())
|
||||
{
|
||||
emit_vptr_on_new_entry = true;
|
||||
}
|
||||
emit_vptr_on_new_entry |= has_entries;
|
||||
|
||||
if let Some(next_inner_most_trait_ref) =
|
||||
siblings.find(|&sibling| visited.insert(sibling.upcast(tcx)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue