Skip to content

Commit 465d24e

Browse files
committed
book: size and align in trait object vtables are used
The book currently claims that the `size` and `align` fields in the trait object vtable are not used, but this is false. These two fields are used by the stable `mem::size_of_val` and `mem::align_of_val` functions. See the `ty::TyDynamic` case of the `glue::size_and_align_of_dst` function in librustc_trans, which is used to implement both intrinsics in the unsized case.
1 parent bd8e9b0 commit 465d24e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/doc/book/trait-objects.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,7 @@ will free the memory. This is necessary for owning trait objects like
264264
`Box<Foo>`, which need to clean-up both the `Box` allocation as well as the
265265
internal type when they go out of scope. The `size` and `align` fields store
266266
the size of the erased type, and its alignment requirements; these are
267-
essentially unused at the moment since the information is embedded in the
268-
destructor, but will be used in the future, as trait objects are progressively
269-
made more flexible.
267+
used by the `std::mem::size_of_val` and `std::mem::align_of_val` functions.
270268

271269
Suppose we’ve got some values that implement `Foo`. The explicit form of
272270
construction and use of `Foo` trait objects might look a bit like (ignoring the

0 commit comments

Comments
 (0)