@@ -1459,9 +1459,20 @@ fn render_impl(
1459
1459
// Only render when the method is not static or we allow static methods
1460
1460
if render_method_item {
1461
1461
let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
1462
+ let source_id = trait_
1463
+ . and_then ( |trait_| trait_
1464
+ . items . iter ( )
1465
+ . find ( |item| item. name . map ( |n| n. as_str ( ) . eq ( & name. as_str ( ) ) ) . unwrap_or ( false ) )
1466
+ ) . map ( |item| format ! ( "{}.{}" , item. type_( ) , name) ) ;
1462
1467
write ! ( w, "<h4 id=\" {}\" class=\" {}{}{}\" >" , id, item_type, extra_class, in_trait_class) ;
1463
1468
w. write_str ( "<code>" ) ;
1464
- render_assoc_item ( w, item, link. anchor ( & id) , ItemType :: Impl , cx) ;
1469
+ render_assoc_item (
1470
+ w,
1471
+ item,
1472
+ link. anchor ( source_id. as_ref ( ) . unwrap_or ( & id) ) ,
1473
+ ItemType :: Impl ,
1474
+ cx
1475
+ ) ;
1465
1476
w. write_str ( "</code>" ) ;
1466
1477
render_stability_since_raw (
1467
1478
w,
@@ -1476,14 +1487,15 @@ fn render_impl(
1476
1487
}
1477
1488
}
1478
1489
clean:: TypedefItem ( ref tydef, _) => {
1479
- let id = cx. derive_id ( format ! ( "{}.{}" , ItemType :: AssocType , name) ) ;
1490
+ let source_id = format ! ( "{}.{}" , ItemType :: AssocType , name) ;
1491
+ let id = cx. derive_id ( source_id. clone ( ) ) ;
1480
1492
write ! ( w, "<h4 id=\" {}\" class=\" {}{}{}\" ><code>" , id, item_type, extra_class, in_trait_class) ;
1481
1493
assoc_type (
1482
1494
w,
1483
1495
item,
1484
1496
& Vec :: new ( ) ,
1485
1497
Some ( & tydef. type_ ) ,
1486
- link. anchor ( & id ) ,
1498
+ link. anchor ( if trait_ . is_some ( ) { & source_id } else { & id } ) ,
1487
1499
"" ,
1488
1500
cx. cache ( ) ,
1489
1501
tcx,
@@ -1493,9 +1505,18 @@ fn render_impl(
1493
1505
w. write_str ( "</h4>" ) ;
1494
1506
}
1495
1507
clean:: AssocConstItem ( ref ty, ref default) => {
1496
- let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
1508
+ let source_id = format ! ( "{}.{}" , item_type, name) ;
1509
+ let id = cx. derive_id ( source_id. clone ( ) ) ;
1497
1510
write ! ( w, "<h4 id=\" {}\" class=\" {}{}{}\" ><code>" , id, item_type, extra_class, in_trait_class) ;
1498
- assoc_const ( w, item, ty, default. as_ref ( ) , link. anchor ( & id) , "" , cx) ;
1511
+ assoc_const (
1512
+ w,
1513
+ item,
1514
+ ty,
1515
+ default. as_ref ( ) ,
1516
+ link. anchor ( if trait_. is_some ( ) { & source_id } else { & id } ) ,
1517
+ "" ,
1518
+ cx
1519
+ ) ;
1499
1520
w. write_str ( "</code>" ) ;
1500
1521
render_stability_since_raw (
1501
1522
w,
@@ -1509,14 +1530,15 @@ fn render_impl(
1509
1530
w. write_str ( "</h4>" ) ;
1510
1531
}
1511
1532
clean:: AssocTypeItem ( ref bounds, ref default) => {
1512
- let id = cx. derive_id ( format ! ( "{}.{}" , item_type, name) ) ;
1533
+ let source_id = format ! ( "{}.{}" , item_type, name) ;
1534
+ let id = cx. derive_id ( source_id. clone ( ) ) ;
1513
1535
write ! ( w, "<h4 id=\" {}\" class=\" {}{}{}\" ><code>" , id, item_type, extra_class, in_trait_class) ;
1514
1536
assoc_type (
1515
1537
w,
1516
1538
item,
1517
1539
bounds,
1518
1540
default. as_ref ( ) ,
1519
- link. anchor ( & id ) ,
1541
+ link. anchor ( if trait_ . is_some ( ) { & source_id } else { & id } ) ,
1520
1542
"" ,
1521
1543
cx. cache ( ) ,
1522
1544
tcx,
@@ -1613,7 +1635,7 @@ fn render_impl(
1613
1635
true ,
1614
1636
outer_version,
1615
1637
outer_const_version,
1616
- None ,
1638
+ Some ( t ) ,
1617
1639
show_def_docs,
1618
1640
) ;
1619
1641
}
0 commit comments