Skip to content

Commit 97623bf

Browse files
committed
Don't hide fields of enum struct variants
* The toggle adds visual clutter * It's easy to miss that there are fields * Tuple variant fields are always shown, so it is inconsistent to hide struct variant fields * It's annoying to have to click the toggle every time
1 parent e742158 commit 97623bf

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/librustdoc/html/render/print_item.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1029,14 +1029,12 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10291029

10301030
use crate::clean::Variant;
10311031
if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
1032-
let count_fields = s.fields.len();
1033-
toggle_open(w, format_args!("{} field{}", count_fields, pluralize(count_fields)));
10341032
let variant_id = cx.derive_id(format!(
10351033
"{}.{}.fields",
10361034
ItemType::Variant,
10371035
variant.name.as_ref().unwrap()
10381036
));
1039-
write!(w, "<div class=\"autohide sub-variant\" id=\"{id}\">", id = variant_id);
1037+
write!(w, "<div class=\"sub-variant\" id=\"{id}\">", id = variant_id);
10401038
write!(
10411039
w,
10421040
"<h3>Fields of <b>{name}</b></h3><div>",
@@ -1064,7 +1062,6 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
10641062
}
10651063
}
10661064
w.write_str("</div></div>");
1067-
toggle_close(w);
10681065
}
10691066
}
10701067
}

src/librustdoc/html/static/css/rustdoc.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ a.test-arrow:hover{
10721072
padding-top: 1px;
10731073
}
10741074

1075-
#main > details > .sub-variant > h3 {
1075+
#main .sub-variant > h3 {
10761076
font-size: 15px;
10771077
margin-left: 25px;
10781078
margin-bottom: 5px;

src/test/rustdoc/toggle-item-contents.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ pub struct PrivStruct {
6262
}
6363

6464
// @has 'toggle_item_contents/enum.Enum.html'
65-
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1
66-
// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 2 fields'
65+
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]'
6766
pub enum Enum {
6867
A, B, C,
6968
D {
@@ -73,8 +72,7 @@ pub enum Enum {
7372
}
7473

7574
// @has 'toggle_item_contents/enum.EnumStructVariant.html'
76-
// @count - '//details[@class="rustdoc-toggle type-contents-toggle"]' 1
77-
// @has - '//details[@class="rustdoc-toggle type-contents-toggle"]' 'Show 1 field'
75+
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]'
7876
pub enum EnumStructVariant {
7977
A, B, C,
8078
D {

0 commit comments

Comments
 (0)