-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use #[rustc_layout] instead of print-type-sizes #69852
Comments
We should add a "Compiler attributes" chapter to the Rust Unstable book and include it there. |
Here is the blog post I wrote 1.5 years ago about I see two major disadvantages of
(I had also been hoping that Therefore, |
This is merely the result of The best thing IMO would be an unified output (if we even keep the flag) that is both human-readable and lossless (so that any change would be reflected in layout tests).
I agree, we should have a recursive mode (stopping only at pointers/references), or even make it the default. I could see this being useful for @RalfJung as well. If we do want to keep the flag, I would at least change "sizes" to "layout" and maybe "print" to "dump". An alternative to stabilization could be moving the flag to It doesn't fit well at all with incremental though, and someone on Discord even pointed out how they wasted time because the flag didn't seem to work until they ran (The conflict with incremental is worse than that theoretically, but since it's an "output (side-)effect", it doesn't really affect soundness, so it's arguably just an odd form of debug logging) We could even decide to let |
I agree that |
Yeah that seems reasonable, if we can make it not overwhelming in terms of the sheer amounts of output. |
Should we add some documentation regarding the use of Also, I found enum A {
#[rustc_layout(size)]
A(Weird),
} |
Yes that seems like a good idea.
Maybe |
I don't know if recurseing everything below is a nice idea, one layer seemed good enough for me, not sure about others. By the way, I used this because Maybe this is better? If |
I definitely do want to be able to recurse fully. For a complex type, I often want to see every component of it down to the individual scalars. |
@pickfire I would very much welcome documentation PRs for the unstable book! |
If I understand correctly, there is another problem with relying solely on So, for example, you cannot use it to get the sizes of closures
(Of course we could fix this by e.g. extending the attribute further so that you could attach it to Anyway, my basic viewpoint is that we should have both things. |
This applies to closures and any other types equally FWIW. Would be interesting to apply the attribute to a
I somewhat agree, but to be specific and clear: I think OTOH "print type sizes" doesn't feel right as a name, but I don't have good suggestions. "report layouts" maybe? |
@eddyb suggested that the
#[rustc_layout]
attribute (usage example) should be improved to replace-Z print-type-sizes
and then be used for these tests. Then the tests also would not have to beignore-pass
any more.That attribute also seems very useful when working with
LayoutDetails
in general in Rust, I would have loved to know about its existence. I wonder what would be a good place to document it?Also see this blog post on
rustc_layout
.The text was updated successfully, but these errors were encountered: