Rustdoc: report layout of enum variants #86253
Labels
A-rustdoc-type-layout
Area: `rustdoc --show-type-layout` (nightly-only)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
#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 aTyAndLayout
. We want to handle the case wherety_layout.layout.variants
isVariants::Multiple
.In that case we have access to anIndexVec<VariantIdx, Layout>
.Layout
part will give us the size of the variantAdtDef
stored inTyKind::Adt
, which we can hopefully get fromty_layout.ty.kind
.The text was updated successfully, but these errors were encountered: