Skip to content

Commit

Permalink
Rollup merge of rust-lang#123116 - chloekek:rustdoc-variant-swap-fiel…
Browse files Browse the repository at this point in the history
…ds-doc, r=GuillaumeGomez

rustdoc: Swap fields and variant documentations

Previously, the documentation for a variant appeared after the documentation for each of its fields. This was inconsistent with structs and unions, and made little sense on its own; fields are subordinate to variants and should therefore appear later in the documentation.

Before:

![Screenshot of rendered documentation before this patch.](https://github.com/rust-lang/rust/assets/50083900/4c98258e-bdf7-4507-9cf1-fe601407ff11)

After:

![Screenshot of rendered documentation after this patch.](https://github.com/rust-lang/rust/assets/50083900/bd223f92-9b06-4b5a-820e-7a8501bdc0e2)
  • Loading branch information
GuillaumeGomez committed Mar 27, 2024
2 parents 64a9360 + 1942f95 commit c0945f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Expand Up @@ -1728,6 +1728,8 @@ fn item_variants(
}
w.write_str("</h3></section>");

write!(w, "{}", document(cx, variant, Some(it), HeadingOffset::H4));

let heading_and_fields = match &variant_data.kind {
clean::VariantKind::Struct(s) => {
// If there is no field to display, no need to add the heading.
Expand Down Expand Up @@ -1789,8 +1791,6 @@ fn item_variants(
}
w.write_str("</div>");
}

write!(w, "{}", document(cx, variant, Some(it), HeadingOffset::H4));
}
write!(w, "</div>");
}
Expand Down

0 comments on commit c0945f0

Please sign in to comment.