diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index dcb8635ade632..520d1c77a87cb 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -1457,8 +1457,8 @@ fn render_impl(
}
fn render_default_items(
- w: &mut Buffer,
- tmp_w: &mut Buffer,
+ boring: &mut Buffer,
+ interesting: &mut Buffer,
cx: &Context<'_>,
t: &clean::Trait,
i: &clean::Impl,
@@ -1477,8 +1477,8 @@ fn render_impl(
let assoc_link = AssocItemLink::GotoSource(did, &i.provided_trait_methods);
doc_impl_item(
- w,
- tmp_w,
+ boring,
+ interesting,
cx,
trait_item,
parent,
@@ -1513,10 +1513,14 @@ fn render_impl(
);
}
}
- let details_str = if impl_items.is_empty() && default_impl_items.is_empty() {
- ""
- } else {
- ""
+ let toggled = !impl_items.is_empty() || !default_impl_items.is_empty();
+ let open_details = |close_tags: &mut String| {
+ if toggled {
+ close_tags.insert_str(0, "
"
+ } else {
+ ""
+ }
};
if render_mode == RenderMode::Normal {
let id = cx.derive_id(match i.inner_impl().trait_ {
@@ -1538,11 +1542,10 @@ fn render_impl(
write!(
w,
"{}
",
- details_str, id, aliases
+ open_details(&mut close_tags),
+ id,
+ aliases
);
- if !impl_items.is_empty() || !default_impl_items.is_empty() {
- close_tags.insert_str(0, "
{}
",
- details_str,
+ open_details(&mut close_tags),
id,
aliases,
i.inner_impl().print(false, cx)
);
- if !impl_items.is_empty() || !default_impl_items.is_empty() {
- close_tags.insert_str(0, "");
- }
}
write!(w, "", id);
render_stability_since_raw(
@@ -1584,7 +1584,7 @@ fn render_impl(
outer_const_version,
);
write_srclink(cx, &i.impl_item, w);
- if impl_items.is_empty() && default_impl_items.is_empty() {
+ if !toggled {
w.write_str("