rust-playground
rust-playground copied to clipboard
Add an option to show sizes of used types using -Zprint-type-sizes
Compiling with cargo +nightly rustc -- -Zprint-type-sizes provides a nice type size printout that would be nice to have on the playground. Example from https://nnethercote.github.io/perf-book/type-sizes.html:
print-type-size type: `E`: 32 bytes, alignment: 8 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `D`: 31 bytes
print-type-size padding: 7 bytes
print-type-size field `.0`: 24 bytes, alignment: 8 bytes
print-type-size variant `C`: 23 bytes
...
It would be very handy to be able to quickly see this output in the playground, to help validate layout concerns. All that is needed is an extra button that directly displays the compiler output, or optionally strips the leading print-type-size first.
Relevant: https://github.com/rust-lang/rust/issues/69852