Skip to content

Commit 1c556bb

Browse files
Don't generate the "Fields" heading if there is no field displayed
1 parent cf8d812 commit 1c556bb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustdoc/html/render/print_item.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,14 @@ fn item_variants(
17371737
w.write_str("</h3></section>");
17381738

17391739
let heading_and_fields = match &variant_data.kind {
1740-
clean::VariantKind::Struct(s) => Some(("Fields", &s.fields)),
1740+
clean::VariantKind::Struct(s) => {
1741+
// If there is no field to display, no need to add the heading.
1742+
if s.fields.iter().any(|f| !f.is_doc_hidden()) {
1743+
Some(("Fields", &s.fields))
1744+
} else {
1745+
None
1746+
}
1747+
}
17411748
clean::VariantKind::Tuple(fields) => {
17421749
// Documentation on tuple variant fields is rare, so to reduce noise we only emit
17431750
// the section if at least one field is documented.

0 commit comments

Comments
 (0)