@@ -773,22 +773,25 @@ fn assoc_const(
773
773
fn assoc_type (
774
774
w : & mut Buffer ,
775
775
it : & clean:: Item ,
776
+ generics : & clean:: Generics ,
776
777
bounds : & [ clean:: GenericBound ] ,
777
778
default : Option < & clean:: Type > ,
778
779
link : AssocItemLink < ' _ > ,
779
- extra : & str ,
780
+ indent : usize ,
780
781
cx : & Context < ' _ > ,
781
782
) {
782
783
write ! (
783
784
w,
784
- "{}type <a href=\" {}\" class=\" associatedtype\" >{}</a>" ,
785
- extra,
786
- naive_assoc_href( it, link, cx) ,
787
- it. name. as_ref( ) . unwrap( )
785
+ "{indent}type <a href=\" {href}\" class=\" associatedtype\" >{name}</a>{generics}" ,
786
+ indent = " " . repeat( indent) ,
787
+ href = naive_assoc_href( it, link, cx) ,
788
+ name = it. name. as_ref( ) . unwrap( ) ,
789
+ generics = generics. print( cx) ,
788
790
) ;
789
791
if !bounds. is_empty ( ) {
790
792
write ! ( w, ": {}" , print_generic_bounds( bounds, cx) )
791
793
}
794
+ write ! ( w, "{}" , print_where_clause( generics, cx, indent, false ) ) ;
792
795
if let Some ( default) = default {
793
796
write ! ( w, " = {}" , default . print( cx) )
794
797
}
@@ -812,11 +815,8 @@ fn assoc_method(
812
815
AssocItemLink :: GotoSource ( did, provided_methods) => {
813
816
// We're creating a link from an impl-item to the corresponding
814
817
// trait-item and need to map the anchored type accordingly.
815
- let ty = if provided_methods. contains ( name) {
816
- ItemType :: Method
817
- } else {
818
- ItemType :: TyMethod
819
- } ;
818
+ let ty =
819
+ if provided_methods. contains ( name) { ItemType :: Method } else { ItemType :: TyMethod } ;
820
820
821
821
match ( href ( did. expect_def_id ( ) , cx) , ty) {
822
822
( Ok ( p) , ty) => Some ( format ! ( "{}#{}.{}" , p. 0 , ty, name) ) ,
@@ -974,13 +974,14 @@ fn render_assoc_item(
974
974
clean:: AssocConstItem ( ref ty, _) => {
975
975
assoc_const ( w, item, ty, link, if parent == ItemType :: Trait { " " } else { "" } , cx)
976
976
}
977
- clean:: AssocTypeItem ( ref bounds, ref default) => assoc_type (
977
+ clean:: AssocTypeItem ( ref generics , ref bounds, ref default) => assoc_type (
978
978
w,
979
979
item,
980
+ generics,
980
981
bounds,
981
982
default. as_ref ( ) ,
982
983
link,
983
- if parent == ItemType :: Trait { " " } else { "" } ,
984
+ if parent == ItemType :: Trait { 4 } else { 0 } ,
984
985
cx,
985
986
) ,
986
987
_ => panic ! ( "render_assoc_item called on non-associated-item" ) ,
@@ -1284,7 +1285,16 @@ fn notable_traits_decl(decl: &clean::FnDecl, cx: &Context<'_>) -> String {
1284
1285
let empty_set = FxHashSet :: default ( ) ;
1285
1286
let src_link =
1286
1287
AssocItemLink :: GotoSource ( trait_did. into ( ) , & empty_set) ;
1287
- assoc_type ( & mut out, it, & [ ] , Some ( & tydef. type_ ) , src_link, "" , cx) ;
1288
+ assoc_type (
1289
+ & mut out,
1290
+ it,
1291
+ & tydef. generics ,
1292
+ & [ ] ,
1293
+ Some ( & tydef. type_ ) ,
1294
+ src_link,
1295
+ 0 ,
1296
+ cx,
1297
+ ) ;
1288
1298
out. push_str ( ";</span>" ) ;
1289
1299
}
1290
1300
}
@@ -1463,10 +1473,11 @@ fn render_impl(
1463
1473
assoc_type (
1464
1474
w,
1465
1475
item,
1466
- & Vec :: new ( ) ,
1476
+ & tydef. generics ,
1477
+ & [ ] ,
1467
1478
Some ( & tydef. type_ ) ,
1468
1479
link. anchor ( if trait_. is_some ( ) { & source_id } else { & id } ) ,
1469
- "" ,
1480
+ 0 ,
1470
1481
cx,
1471
1482
) ;
1472
1483
w. write_str ( "</h4>" ) ;
@@ -1494,7 +1505,7 @@ fn render_impl(
1494
1505
w. write_str ( "</h4>" ) ;
1495
1506
w. write_str ( "</section>" ) ;
1496
1507
}
1497
- clean:: AssocTypeItem ( ref bounds, ref default) => {
1508
+ clean:: AssocTypeItem ( ref generics , ref bounds, ref default) => {
1498
1509
let source_id = format ! ( "{}.{}" , item_type, name) ;
1499
1510
let id = cx. derive_id ( source_id. clone ( ) ) ;
1500
1511
write ! ( w, "<section id=\" {}\" class=\" {}{}\" >" , id, item_type, in_trait_class, ) ;
@@ -1503,10 +1514,11 @@ fn render_impl(
1503
1514
assoc_type (
1504
1515
w,
1505
1516
item,
1517
+ generics,
1506
1518
bounds,
1507
1519
default. as_ref ( ) ,
1508
1520
link. anchor ( if trait_. is_some ( ) { & source_id } else { & id } ) ,
1509
- "" ,
1521
+ 0 ,
1510
1522
cx,
1511
1523
) ;
1512
1524
w. write_str ( "</h4>" ) ;
@@ -1727,7 +1739,16 @@ pub(crate) fn render_impl_summary(
1727
1739
for it in & i. inner_impl ( ) . items {
1728
1740
if let clean:: TypedefItem ( ref tydef, _) = * it. kind {
1729
1741
w. write_str ( "<span class=\" where fmt-newline\" > " ) ;
1730
- assoc_type ( w, it, & [ ] , Some ( & tydef. type_ ) , AssocItemLink :: Anchor ( None ) , "" , cx) ;
1742
+ assoc_type (
1743
+ w,
1744
+ it,
1745
+ & tydef. generics ,
1746
+ & [ ] ,
1747
+ Some ( & tydef. type_ ) ,
1748
+ AssocItemLink :: Anchor ( None ) ,
1749
+ 0 ,
1750
+ cx,
1751
+ ) ;
1731
1752
w. write_str ( ";</span>" ) ;
1732
1753
}
1733
1754
}
0 commit comments