about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2023-12-04 12:12:13 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2023-12-04 12:12:13 +0100
commit1c556bbed4a02a914c152c96c18c04835338ba83 (patch)
tree46e84fdd0662013bcd9ce06393a52f9c8afdfefb
parentcf8d81213c193fc0ca9f2b99165476f8ae028295 (diff)
downloadrust-1c556bbed4a02a914c152c96c18c04835338ba83.tar.gz
rust-1c556bbed4a02a914c152c96c18c04835338ba83.zip
Don't generate the "Fields" heading if there is no field displayed
-rw-r--r--src/librustdoc/html/render/print_item.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 131b1d608e6..ff7ce01e807 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -1737,7 +1737,14 @@ fn item_variants(
         w.write_str("</h3></section>");
 
         let heading_and_fields = match &variant_data.kind {
-            clean::VariantKind::Struct(s) => Some(("Fields", &s.fields)),
+            clean::VariantKind::Struct(s) => {
+                // If there is no field to display, no need to add the heading.
+                if s.fields.iter().any(|f| !f.is_doc_hidden()) {
+                    Some(("Fields", &s.fields))
+                } else {
+                    None
+                }
+            }
             clean::VariantKind::Tuple(fields) => {
                 // Documentation on tuple variant fields is rare, so to reduce noise we only emit
                 // the section if at least one field is documented.