pub struct VTable {
pub trait_names: Vec<String>,
pub concrete_type_id: u32,
pub methods: HashMap<String, VTableEntry>,
}Expand description
Virtual method table for trait objects.
Maps method names to entries describing how each method dispatches
through a dyn Trait receiver. Built at vtable-construction time
(compile-time per (impl Trait for Type) pair) and shared via
Arc<VTable> from the TraitObjectStorage fat-pointer carrier.
ADR-006 §2.7.24 Q25.C.5 — extended shape (W17-trait-object-storage,
2026-05-11): the legacy 2-variant VTableEntry { FunctionId, Closure }
is widened to 6 variants (Direct / Closure / BoxedReturn /
SelfArg / Generic / Compound) to encode the per-method
rewriting that Erase_T performs on the method signature when the
trait is used as dyn T. Per-(impl, method) thunks are emitted at
vtable-construction time; the thunk_id fields below name them.
Fields§
§trait_names: Vec<String>Trait names this vtable implements. Supports multi-trait
inheritance — when an impl spans T: A + B + C, all three trait
names appear here in order so the §Q25.C.2 vtable-identity check
can compare across the inheritance chain.
concrete_type_id: u32Concrete-type discriminator for the underlying boxed value.
Enables the §Q25.C.2 Self-arg runtime check (Arc::ptr_eq on
vtables is a tighter equality, but concrete_type_id is needed
for the cross-vtable comparison error message and IC-stabilization
key in §Q25.C.6).
methods: HashMap<String, VTableEntry>Map from method name to dispatch entry.