@@ -1457,8 +1457,8 @@ fn render_impl(
14571457 }
14581458
14591459 fn render_default_items (
1460- w : & mut Buffer ,
1461- tmp_w : & mut Buffer ,
1460+ boring : & mut Buffer ,
1461+ interesting : & mut Buffer ,
14621462 cx : & Context < ' _ > ,
14631463 t : & clean:: Trait ,
14641464 i : & clean:: Impl ,
@@ -1477,8 +1477,8 @@ fn render_impl(
14771477 let assoc_link = AssocItemLink :: GotoSource ( did, & i. provided_trait_methods ) ;
14781478
14791479 doc_impl_item (
1480- w ,
1481- tmp_w ,
1480+ boring ,
1481+ interesting ,
14821482 cx,
14831483 trait_item,
14841484 parent,
@@ -1513,10 +1513,14 @@ fn render_impl(
15131513 ) ;
15141514 }
15151515 }
1516- let details_str = if impl_items. is_empty ( ) && default_impl_items. is_empty ( ) {
1517- ""
1518- } else {
1519- "<details class=\" rustdoc-toggle implementors-toggle\" open><summary>"
1516+ let toggled = !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) ;
1517+ let open_details = |close_tags : & mut String | {
1518+ if toggled {
1519+ close_tags. insert_str ( 0 , "</details>" ) ;
1520+ "<details class=\" rustdoc-toggle implementors-toggle\" open><summary>"
1521+ } else {
1522+ ""
1523+ }
15201524 } ;
15211525 if render_mode == RenderMode :: Normal {
15221526 let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
@@ -1538,11 +1542,10 @@ fn render_impl(
15381542 write ! (
15391543 w,
15401544 "{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >" ,
1541- details_str, id, aliases
1545+ open_details( & mut close_tags) ,
1546+ id,
1547+ aliases
15421548 ) ;
1543- if !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) {
1544- close_tags. insert_str ( 0 , "</details>" ) ;
1545- }
15461549 write ! ( w, "{}" , i. inner_impl( ) . print( use_absolute, cx) ) ;
15471550 if show_def_docs {
15481551 for it in & i. inner_impl ( ) . items {
@@ -1566,14 +1569,11 @@ fn render_impl(
15661569 write ! (
15671570 w,
15681571 "{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >{}</code>" ,
1569- details_str ,
1572+ open_details ( & mut close_tags ) ,
15701573 id,
15711574 aliases,
15721575 i. inner_impl( ) . print( false , cx)
15731576 ) ;
1574- if !impl_items. is_empty ( ) || !default_impl_items. is_empty ( ) {
1575- close_tags. insert_str ( 0 , "</details>" ) ;
1576- }
15771577 }
15781578 write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
15791579 render_stability_since_raw (
@@ -1584,7 +1584,7 @@ fn render_impl(
15841584 outer_const_version,
15851585 ) ;
15861586 write_srclink ( cx, & i. impl_item , w) ;
1587- if impl_items . is_empty ( ) && default_impl_items . is_empty ( ) {
1587+ if !toggled {
15881588 w. write_str ( "</h3>" ) ;
15891589 } else {
15901590 w. write_str ( "</h3></summary>" ) ;
@@ -1613,7 +1613,7 @@ fn render_impl(
16131613 ) ;
16141614 }
16151615 }
1616- if !impl_items . is_empty ( ) || !default_impl_items . is_empty ( ) {
1616+ if toggled {
16171617 w. write_str ( "<div class=\" impl-items\" >" ) ;
16181618 w. push_buffer ( default_impl_items) ;
16191619 if trait_. is_some ( ) && !impl_items. is_empty ( ) {
0 commit comments