Uh oh!
There was an error while loading. Please reload this page.
Rustdoc: Report Layout of enum variants - #86263
Conversation
rust-highfive
commented
Jun 13, 2021
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
a6747c4 to
7c87a39CompareUh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
7c87a39 to
4a2e8adCompareUh oh!
There was an error while loading. Please reload this page.
4a2e8ad to
1ab9596CompareThere was a problem hiding this comment.
Can you test what happens for the empty case? Does it show 0 bytes or unsized? I think ideally it would show "uninhabited" or something.
There was a problem hiding this comment.
It shows 0 bytes. I think it would be more suitable for a separate PR as a followup of the original PR.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Then it wouldn't matter because its size is already reported previously.
pickfire
commented
Jul 10, 2021
@fee1-dead Do you have a sample screenshot on how it looks like? |
Uh oh!
There was an error while loading. Please reload this page.
fee1-dead
commented
Jul 10, 2021
@rustbot label -S-waiting-on-author S-waiting-on-review |
jyn514
commented
Jul 10, 2021
@fee1-dead hmm, that doesn't seem super helpful - I assume those are all 0 because they don't have fields? Could we avoid showing the size in that case and only report it for fields? Actually at that point I'm not really sure how much purpose this serves - why wouldn't the user just look at the size shown for the type in the field? |
@camelid do you have opinions on #86263 (comment) ? |
camelid
commented
Aug 30, 2021
I find it annoying to have to click on each field's type to try to manually compute its size, especially if the type is something like I think it'd be useful to have a summary of the sizes of each variant. Is that what you were asking about, or was it something else? |
jyn514
commented
Aug 30, 2021
👍 makes sense, I hadn't thought about anonymous types. Ok, I think this makes sense then. |
ae9e562 to
5f1505eCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // @has type_layout/enum.Variants.html 'Size: ' | ||
| // @has - '2 bytes' | ||
| // @has - '<code>A</code>: 0 bytes' | ||
| // @has - '<code>B</code>: 1 byte' |
There was a problem hiding this comment.
Just to confirm: this checks that this "text" is in the raw HTML directly, right?
There was a problem hiding this comment.
What's odd is I tried @has - '<strong>Size:</strong> 8 bytes on master on an existing test case, but it failed. I'm not sure why these tests are passing.
5065be6 to
c0451f7Comparecamelid
commented
Sep 6, 2021
Thanks! @bors r+ rollup |
bors
commented
Sep 6, 2021
📌 Commit c0451f7 has been approved by |
Rollup of 9 pull requests Successful merges: - rust-lang#86263 (Rustdoc: Report Layout of enum variants) - rust-lang#88541 (Add regression test for rust-lang#74400) - rust-lang#88553 (Improve diagnostics for unary plus operators (rust-lang#88276)) - rust-lang#88594 (More symbolic doc aliases) - rust-lang#88648 (Correct “copies” to “moves” in `<Option<T> as From<T>>::from` doc, and other copyediting) - rust-lang#88691 (Add a regression test for rust-lang#88649) - rust-lang#88694 (Drop 1.56 stabilizations from 1.55 release notes) - rust-lang#88712 (Fix docs for `uX::checked_next_multiple_of`) - rust-lang#88726 (Fix typo in `const_generics` replaced with `adt_const_params` note) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Add layout info for enum variant and locals The size of enum variant is what rustdoc shows (rust-lang/rust#86263). I also added layout info for locals since it helps finding size of unnameable types like closures inside other structs or impl traits.

Followup of #83501, Fixes#86253.
cc @camelid
@rustbot label A-rustdoc