Skip to content

Emit layout information for unsized types #257

Description

@spernsteiner

Currently, mir-json outputs layout information size, align, and field offsets only for sized types. Unsized types don't have a size, but they may have a statically-known alignment and/or field offsets. Specifically:

  • [T] has a statically known alignment, but an unknown number of fields
  • dyn Trait does not have statically known alignment or fields
  • MyStruct<[T]> (a custom DST with [T] tail) has a statically known alignment and statically known field offsets (the last field of the struct being [T], which has unknown size and field count)
  • MyStruct<dyn Trait> has unknown alignment, though it must be at least as high as the maximum alignment among the non-last fields of MyStruct (but it could be higher depending on the alignment of the erased type). It has statically-known offsets for all of the non-last fields, but the offset of the last field may vary depending on the alignment of the erased type and thus is not statically known.

This playground demonstrates the custom DST cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions