News for hackers. Stuff that matters.
Re:Optimizing Rust Struct Size by ryanschneider on Saturday April 15, 2017 @09:28PM (#14123863)
What if there was an option to rewrite the source .rs file into the matching layout? I'd imagine that could be useful in scenarios where one has to manually do something with a dump or disassembly, etc. Plus then it could be linted against if a project wanted to ("code does not match in memory layout, use --rearrange-structs to correct").
Re:Optimizing Rust Struct Size by CUViper on Saturday April 15, 2017 @10:45PM (#14124077)
In generic code, the generated layouts can't even be written in a universal way, because they can vary depending on those input types.
Re:Optimizing Rust Struct Size by eddyb on Sunday April 16, 2017 @06:50AM (#14125285)
You can get it from debuginfo - just load your binary into any debug session (this might even work with no execution or core dump, just a blob of memory that from your program) and then you can cast char* to YourRustType* to be able to introspect it.

On top of that, on nightly you have this flag: -Z print-type-sizes -- print layout information for each type encountered

This is what the output looks like: https://github.com/rust-lang/rust/blob/13fd5e93deb41045c4de8...