Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 20b30ac

Browse files
committed
Include a warning in the layout docs that layout is unstable
1 parent 5859c5d commit 20b30ac

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/librustdoc/html/render/print_item.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,10 +1537,19 @@ fn document_ty_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
15371537
let ty = cx.tcx().type_of(ty_def_id);
15381538
match cx.tcx().layout_of(param_env.and(ty)) {
15391539
Ok(ty_layout) => {
1540-
writeln!(w, r#"<h2 class="small-section-header">Layout</h2>"#);
1541-
writeln!(w, "<div>");
1540+
writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>");
1541+
writeln!(w, "<div class=\"docblock\">");
1542+
writeln!(
1543+
w,
1544+
"<div class=\"warning\"><p><strong>Note:</strong> Most layout information is \
1545+
completely unstable and may be different between compiler versions. \
1546+
The only exception is types with certain <code>repr(...)</code> attributes. \
1547+
Please see the Rust Reference’s \
1548+
<a href=\"https://doc.rust-lang.org/reference/type-layout.html\">“Type Layout”</a> \
1549+
chapter for details on type layout guarantees.</p></div>"
1550+
);
15421551
if ty_layout.layout.abi.is_unsized() {
1543-
writeln!(w, "<strong>Sized:</strong> (unsized)");
1552+
writeln!(w, "<p><strong>Size:</strong> (unsized)</p>");
15441553
} else {
15451554
writeln!(
15461555
w,

0 commit comments

Comments
 (0)