Skip to content

Document --show-type-layout in the rustdoc book #89164

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

Merged
merged 4 commits into from
Sep 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
writeln!(
w,
"<div class=\"warning\"><p><strong>Note:</strong> Most layout information is \
completely unstable and may be different between compiler versions and platforms. \
completely unstable and may even differ between compilations. \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can this be true? The compiler has to be able to depend on the ABI to create dynamic libraries.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Reference (emphasis mine):

Type layout can be changed with each compilation. Instead of trying to document exactly what is done, we only document what is guaranteed today.

I assume that means that the compiler is free to change layout if your crate is a static library or a binary. Also, there are (future) flags like -Z randomize-layout which would change layout between compilations.

The only exception is types with certain <code>repr(...)</code> attributes. \
Please see the Rust Reference’s \
<a href=\"https://doc.rust-lang.org/reference/type-layout.html\">“Type Layout”</a> \
Expand Down