From 372159011839d38aac18fd27695324f6deaf761d Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 31 May 2021 23:36:39 +0800 Subject: [PATCH] Add full debug layout for type layout doc See what you can see for `#[rustc_layout(debug)]` but with rustdoc which is very useful, rather than writing some stuff you can just browse through the docs. I think it may be useful to put it in json and have something process it and do sort of `ncdu` to easily optimize on type sizes. --- src/librustdoc/html/render/print_item.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index e06168c708c18..d95633302ac49 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1570,6 +1570,14 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) { pl = if bytes == 1 { "" } else { "s" }, ); } + writeln!( + w, + "
\ + Full debug layout\ +
{:#?}
\ +
", + ty_layout.layout, + ); } // This kind of layout error can occur with valid code, e.g. if you try to // get the layout of a generic type such as `Vec`.