Closed
Description
#83501 introduced a basic section on layout information, with only one piece of information: the total size of the type. I think one useful but easy extension to this is reporting the size of each variant for an enum.
cc @camelid
Implementation hints
The "Layout" section is rendered in
rust/src/librustdoc/html/render/print_item.rs
Lines 1553 to 1574 in da7ada5
The ty_layout
variable is a TyAndLayout
. We want to handle the case where ty_layout.layout.variants
is Variants::Multiple
.In that case we have access to an IndexVec<VariantIdx, Layout>
.
- The
Layout
part will give us the size of the variant - To get the name of the variant, we'll need the
AdtDef
stored inTyKind::Adt
, which we can hopefully get fromty_layout.ty.kind
.