@@ -1281,99 +1281,6 @@ fn render_impl(
12811281 let trait_ = i. trait_did_full ( cache) . map ( |did| & traits[ & did] ) ;
12821282 let mut close_tags = String :: new ( ) ;
12831283
1284- if render_mode == RenderMode :: Normal {
1285- let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
1286- Some ( ref t) => {
1287- if is_on_foreign_type {
1288- get_id_for_impl_on_foreign_type ( & i. inner_impl ( ) . for_ , t, cx)
1289- } else {
1290- format ! ( "impl-{}" , small_url_encode( format!( "{:#}" , t. print( cx) ) ) )
1291- }
1292- }
1293- None => "impl" . to_string ( ) ,
1294- } ) ;
1295- let aliases = if aliases. is_empty ( ) {
1296- String :: new ( )
1297- } else {
1298- format ! ( " aliases=\" {}\" " , aliases. join( "," ) )
1299- } ;
1300- if let Some ( use_absolute) = use_absolute {
1301- write ! (
1302- w,
1303- "<details class=\" rustdoc-toggle implementors-toggle\" open>\
1304- <summary>\
1305- <h3 id=\" {}\" class=\" impl\" {}>\
1306- <code class=\" in-band\" >",
1307- id, aliases
1308- ) ;
1309- close_tags. insert_str ( 0 , "</details>" ) ;
1310- write ! ( w, "{}" , i. inner_impl( ) . print( use_absolute, cx) ) ;
1311- if show_def_docs {
1312- for it in & i. inner_impl ( ) . items {
1313- if let clean:: TypedefItem ( ref tydef, _) = * it. kind {
1314- w. write_str ( "<span class=\" where fmt-newline\" > " ) ;
1315- assoc_type (
1316- w,
1317- it,
1318- & [ ] ,
1319- Some ( & tydef. type_ ) ,
1320- AssocItemLink :: Anchor ( None ) ,
1321- "" ,
1322- cx,
1323- ) ;
1324- w. write_str ( ";</span>" ) ;
1325- }
1326- }
1327- }
1328- w. write_str ( "</code>" ) ;
1329- } else {
1330- write ! (
1331- w,
1332- "<details class=\" rustdoc-toggle implementors-toggle\" open>\
1333- <summary>\
1334- <h3 id=\" {}\" class=\" impl\" {}>\
1335- <code class=\" in-band\" >{}</code>",
1336- id,
1337- aliases,
1338- i. inner_impl( ) . print( false , cx)
1339- ) ;
1340- close_tags. insert_str ( 0 , "</details>" ) ;
1341- }
1342- write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1343- render_stability_since_raw (
1344- w,
1345- i. impl_item . stable_since ( tcx) . as_deref ( ) ,
1346- i. impl_item . const_stable_since ( tcx) . as_deref ( ) ,
1347- outer_version,
1348- outer_const_version,
1349- ) ;
1350- write_srclink ( cx, & i. impl_item , w) ;
1351- w. write_str ( "</h3></summary>" ) ;
1352-
1353- if trait_. is_some ( ) {
1354- if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
1355- write ! ( w, "<div class=\" item-info\" >{}</div>" , portability) ;
1356- }
1357- }
1358-
1359- if let Some ( ref dox) = cx. shared . maybe_collapsed_doc_value ( & i. impl_item ) {
1360- let mut ids = cx. id_map . borrow_mut ( ) ;
1361- write ! (
1362- w,
1363- "<div class=\" docblock\" >{}</div>" ,
1364- Markdown (
1365- & * dox,
1366- & i. impl_item. links( cx) ,
1367- & mut ids,
1368- cx. shared. codes,
1369- cx. shared. edition( ) ,
1370- & cx. shared. playground
1371- )
1372- . into_string( )
1373- ) ;
1374- }
1375- }
1376-
13771284 fn doc_impl_item (
13781285 w : & mut Buffer ,
13791286 cx : & Context < ' _ > ,
@@ -1549,11 +1456,10 @@ fn render_impl(
15491456 }
15501457 }
15511458
1552- w. write_str ( "<div class=\" impl-items\" >" ) ;
1553- close_tags. insert_str ( 0 , "</div>" ) ;
1459+ let mut impl_items = Buffer :: empty_from ( w) ;
15541460 for trait_item in & i. inner_impl ( ) . items {
15551461 doc_impl_item (
1556- w ,
1462+ & mut impl_items ,
15571463 cx,
15581464 trait_item,
15591465 if trait_. is_some ( ) { & i. impl_item } else { parent } ,
@@ -1609,7 +1515,7 @@ fn render_impl(
16091515 if show_default_items {
16101516 if let Some ( t) = trait_ {
16111517 render_default_items (
1612- w ,
1518+ & mut impl_items ,
16131519 cx,
16141520 & t. trait_ ,
16151521 & i. inner_impl ( ) ,
@@ -1621,6 +1527,111 @@ fn render_impl(
16211527 ) ;
16221528 }
16231529 }
1530+ let details_str = if impl_items. is_empty ( ) {
1531+ ""
1532+ } else {
1533+ "<details class=\" rustdoc-toggle implementors-toggle\" open><summary>"
1534+ } ;
1535+ if render_mode == RenderMode :: Normal {
1536+ let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
1537+ Some ( ref t) => {
1538+ if is_on_foreign_type {
1539+ get_id_for_impl_on_foreign_type ( & i. inner_impl ( ) . for_ , t, cx)
1540+ } else {
1541+ format ! ( "impl-{}" , small_url_encode( format!( "{:#}" , t. print( cx) ) ) )
1542+ }
1543+ }
1544+ None => "impl" . to_string ( ) ,
1545+ } ) ;
1546+ let aliases = if aliases. is_empty ( ) {
1547+ String :: new ( )
1548+ } else {
1549+ format ! ( " aliases=\" {}\" " , aliases. join( "," ) )
1550+ } ;
1551+ if let Some ( use_absolute) = use_absolute {
1552+ write ! (
1553+ w,
1554+ "{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >" ,
1555+ details_str, id, aliases
1556+ ) ;
1557+ if !impl_items. is_empty ( ) {
1558+ close_tags. insert_str ( 0 , "</details>" ) ;
1559+ }
1560+ write ! ( w, "{}" , i. inner_impl( ) . print( use_absolute, cx) ) ;
1561+ if show_def_docs {
1562+ for it in & i. inner_impl ( ) . items {
1563+ if let clean:: TypedefItem ( ref tydef, _) = * it. kind {
1564+ w. write_str ( "<span class=\" where fmt-newline\" > " ) ;
1565+ assoc_type (
1566+ w,
1567+ it,
1568+ & [ ] ,
1569+ Some ( & tydef. type_ ) ,
1570+ AssocItemLink :: Anchor ( None ) ,
1571+ "" ,
1572+ cx,
1573+ ) ;
1574+ w. write_str ( ";</span>" ) ;
1575+ }
1576+ }
1577+ }
1578+ w. write_str ( "</code>" ) ;
1579+ } else {
1580+ write ! (
1581+ w,
1582+ "{}<h3 id=\" {}\" class=\" impl\" {}><code class=\" in-band\" >{}</code>" ,
1583+ details_str,
1584+ id,
1585+ aliases,
1586+ i. inner_impl( ) . print( false , cx)
1587+ ) ;
1588+ if !impl_items. is_empty ( ) {
1589+ close_tags. insert_str ( 0 , "</details>" ) ;
1590+ }
1591+ }
1592+ write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1593+ render_stability_since_raw (
1594+ w,
1595+ i. impl_item . stable_since ( tcx) . as_deref ( ) ,
1596+ i. impl_item . const_stable_since ( tcx) . as_deref ( ) ,
1597+ outer_version,
1598+ outer_const_version,
1599+ ) ;
1600+ write_srclink ( cx, & i. impl_item , w) ;
1601+ if impl_items. is_empty ( ) {
1602+ w. write_str ( "</h3>" ) ;
1603+ } else {
1604+ w. write_str ( "</h3></summary>" ) ;
1605+ }
1606+
1607+ if trait_. is_some ( ) {
1608+ if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
1609+ write ! ( w, "<div class=\" item-info\" >{}</div>" , portability) ;
1610+ }
1611+ }
1612+
1613+ if let Some ( ref dox) = cx. shared . maybe_collapsed_doc_value ( & i. impl_item ) {
1614+ let mut ids = cx. id_map . borrow_mut ( ) ;
1615+ write ! (
1616+ w,
1617+ "<div class=\" docblock\" >{}</div>" ,
1618+ Markdown (
1619+ & * dox,
1620+ & i. impl_item. links( cx) ,
1621+ & mut ids,
1622+ cx. shared. codes,
1623+ cx. shared. edition( ) ,
1624+ & cx. shared. playground
1625+ )
1626+ . into_string( )
1627+ ) ;
1628+ }
1629+ }
1630+ if !impl_items. is_empty ( ) {
1631+ w. write_str ( "<div class=\" impl-items\" >" ) ;
1632+ w. push_buffer ( impl_items) ;
1633+ close_tags. insert_str ( 0 , "</div>" ) ;
1634+ }
16241635 w. write_str ( & close_tags) ;
16251636}
16261637
0 commit comments