-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc: Add unstable CLI option to show basic type layout information #83501
Conversation
r? @jyn514 (rust-highfive has picked a reviewer for you, use r? to override) |
Weirdly, it doesn't work on many types (e.g. |
cc @rust-lang/libs - I think this could be a reasonable change, but I also don't want to encourage people to use |
I also think a reasonable choice would be to add an unstable option, |
There's already |
Interesting, I hadn't heard of that flag. But how is it duplication? The flags are very different; the rustc one prints to stdout, while the |
Is there a screenshot of what this looks like? I agree that showing size info could be quite precarious due to platform differences. The obvious concern, I guess, is whether folks reading docs will interpret that size info as an API guarantee. I imagine that in most cases, it isn't. Popping up a level, this kind of info seems useful in fairly limited contexts. Just thinking about my own experience, the number of times I've needed to care about information like this is very very small. |
See #83501 (comment).
Yeah, I'm planning to add a notice to the section saying that type layout is not an API guarantee unless otherwise stated by the library docs, as suggested in #75988 (comment).
I think this sort of information is useful more as a library or application author, rather than user. That's why I suggested making it an off-by-default flag, that could be used like This sort of information is useful when trying to shrink the sizes of types within the compiler or rustdoc itself, and I've also just been curious to see what the sizes are in my own projects. I could use something like |
Is this just meant for compiler-internal use? Otherwise library authors couldn't make that kind of promise for |
People regularly use docs generated for a different platform (with different sizes) than they're targetting, such as the docs on docs.rs and on doc.rust-lang.org. So this should definitely be off by default. As an off-by-default rustdoc feature, I don't think this really concerns the libs team. Personally, I can see myself enabling this feature for some embedded projects. |
No, it's meant for use by other projects too (I can see myself potentially using it on one of my projects). And yes, you're right that library authors can't guarantee |
Rebased so I can use the fancy new |
Still looks good to me. Let's try again! :D @bors: r=jyn514,GuillaumeGomez |
📌 Commit d43701c has been approved by |
Rollup of 8 pull requests Successful merges: - rust-lang#83501 (rustdoc: Add unstable CLI option to show basic type layout information) - rust-lang#85018 (shrinking the deprecated method span) - rust-lang#85124 (rustdoc: remove explicit boolean comparisons.) - rust-lang#85136 (Change param name (k to key and v to value) in std::env module) - rust-lang#85162 (Fix typo in variable name) - rust-lang#85187 (Use .name_str() to format primitive types in error messages) - rust-lang#85191 (Improve rustdoc gui tester) - rust-lang#85196 (Revert "Auto merge of rust-lang#84797 - richkadel:cover-unreachable-statements…) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
@camelid I wanted to try this out but I can't seemed to try it. I did profile = "tools"
changelog-seen = 2 I am using f58631b which was yesterday's commit. |
@pickfire you need --stage 1 |
Followup of rust-lang#83501, Fixes rust-lang#86253.
…r=camelid Rustdoc: Report Layout of enum variants Followup of rust-lang#83501, Fixes rust-lang#86253. cc `@camelid` `@rustbot` label A-rustdoc
At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of rust-lang#83501).
rustdoc: Show type layout for type aliases Fixes rust-lang#91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of rust-lang#83501).
rustdoc: Show type layout for type aliases Fixes rust-lang#91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of rust-lang#83501).
rustdoc: Show type layout for type aliases Fixes rust-lang#91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of rust-lang#83501).
rustdoc: Show type layout for type aliases Fixes rust-lang#91265. At first, you might think, "Why not just click through to the aliased type?" But, if a type alias instantiates all of the generic parameters of the aliased type, then it can show layout info even though the aliased type cannot (because we can't compute layout for generic types). So, I think it's useful to show layout info for type aliases. This is a followup of 78d4b453ad2e19d44011b26fc55c949bff5dba3d (originally part of rust-lang#83501).
Closes #75988.
Right now it just shows the size.