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.
This commit is contained in:
chloekek 2024-03-27 01:17:33 +01:00
parent 47ecded352
commit 1942f956a3

View File

@ -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.
@ -1789,8 +1791,6 @@ fn item_variants(
}
w.write_str("</div>");
}
write!(w, "{}", document(cx, variant, Some(it), HeadingOffset::H4));
}
write!(w, "</div>");
}