Skip to content

Commit

Permalink
rustdoc: Swap fields and variant documentations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chloekek committed Mar 27, 2024
1 parent 47ecded commit 1942f95
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
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 1942f95

Please sign in to comment.