Skip to content

Did the layout of the trait object metadata change? #85648

Closed
@05storm26

Description

@05storm26

I tried this code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a122541641e9a77365b11b861971d578

According to previous information the first usize pointed by the trait object's metadata/vtable is the size of the struct. This is reiterated in the documentation of the https://doc.rust-lang.org/beta/std/ptr/struct.DynMetadata.html. Did the layout of trait object metadata change?

I expected to see this happen: see the struct's size as the first usize pointed by the trait object's metadata pointer.

Instead, this happened: junk value printed, the second usize appears to be the size of the struct and the third is the alignment.

Is this related to the deprecation of std::raw::TraitObject/#84207?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions