Skip to content

Commit 0e3ae8d

Browse files
authored
Rollup merge of #94769 - GuillaumeGomez:collapsed-by-default, r=notriddle
Collapse blanket and auto-trait impls by default Blocked on #94740 (the two first commits come from it). This behaviour was changed in #88490 and apparently wasn't caught since then. You can test it [here](https://rustdoc.crud.net/imperio/collapsed-by-default/test_docs/struct.Foo.html#blanket-implementations). r? ``@notriddle``
2 parents 8505610 + aad4227 commit 0e3ae8d

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

src/librustdoc/html/render/mod.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,13 @@ fn short_item_info(
699699

700700
// Render the list of items inside one of the sections "Trait Implementations",
701701
// "Auto Trait Implementations," "Blanket Trait Implementations" (on struct/enum pages).
702-
fn render_impls(cx: &Context<'_>, w: &mut Buffer, impls: &[&&Impl], containing_item: &clean::Item) {
702+
fn render_impls(
703+
cx: &Context<'_>,
704+
w: &mut Buffer,
705+
impls: &[&&Impl],
706+
containing_item: &clean::Item,
707+
toggle_open_by_default: bool,
708+
) {
703709
let tcx = cx.tcx();
704710
let mut rendered_impls = impls
705711
.iter()
@@ -722,7 +728,7 @@ fn render_impls(cx: &Context<'_>, w: &mut Buffer, impls: &[&&Impl], containing_i
722728
is_on_foreign_type: false,
723729
show_default_items: true,
724730
show_non_assoc_items: true,
725-
toggle_open_by_default: true,
731+
toggle_open_by_default,
726732
},
727733
);
728734
buffer.into_inner()
@@ -1143,7 +1149,7 @@ fn render_assoc_items_inner(
11431149
concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket());
11441150

11451151
let mut impls = Buffer::empty_from(w);
1146-
render_impls(cx, &mut impls, &concrete, containing_item);
1152+
render_impls(cx, &mut impls, &concrete, containing_item, true);
11471153
let impls = impls.into_inner();
11481154
if !impls.is_empty() {
11491155
write!(
@@ -1165,7 +1171,7 @@ fn render_assoc_items_inner(
11651171
</h2>\
11661172
<div id=\"synthetic-implementations-list\">",
11671173
);
1168-
render_impls(cx, w, &synthetic, containing_item);
1174+
render_impls(cx, w, &synthetic, containing_item, false);
11691175
w.write_str("</div>");
11701176
}
11711177

@@ -1177,7 +1183,7 @@ fn render_assoc_items_inner(
11771183
</h2>\
11781184
<div id=\"blanket-implementations-list\">",
11791185
);
1180-
render_impls(cx, w, &blanket_impl, containing_item);
1186+
render_impls(cx, w, &blanket_impl, containing_item, false);
11811187
w.write_str("</div>");
11821188
}
11831189
}

src/test/rustdoc-gui/toggle-docs.goml

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ assert-text: ("#toggle-all-docs", "[−]")
1717
goto: file://|DOC_PATH|/test_docs/struct.Foo.html
1818
// We first check that everything is visible.
1919
assert-text: ("#toggle-all-docs", "[−]")
20-
assert-attribute: ("details.rustdoc-toggle", {"open": ""}, ALL)
20+
assert-attribute: ("#implementations-list details.rustdoc-toggle", {"open": ""}, ALL)
21+
assert-attribute: ("#trait-implementations-list details.rustdoc-toggle", {"open": ""}, ALL)
22+
assert-attribute-false: (
23+
"#blanket-implementations-list > details.rustdoc-toggle",
24+
{"open": ""},
25+
ALL,
26+
)
27+
2128
// We collapse them all.
2229
click: "#toggle-all-docs"
2330
wait-for: 50

0 commit comments

Comments
 (0)