I am recently thinking to look into trait objects and it is unavoidable to consider vtables. how in general a vtable is organized? how a vtable is constructed?
Copying an old comment I wrote up:
vtable_methods query yields all method entries for a specific vtable (that is, the list of all dyn-compatible methods of all transitive supertraits). On every unsizing cast to a trait object these methods are enqueued for code generation (and the drop glue is also added).
Codegen then assembles the vtable from drop glue, size, alignment, and the method pointers. This defines the vtable's layout in memory.
drop_in_place, size, align, function pointers for all methods (for non object-safe methods a null pointer gets written)
that is brilliant! thx for the info.