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