@@ -394,29 +394,22 @@ fn sidebar_assoc_items<'a>(
394394 let cache = cx. cache ( ) ;
395395
396396 let mut assoc_consts = Vec :: new ( ) ;
397+ let mut assoc_types = Vec :: new ( ) ;
397398 let mut methods = Vec :: new ( ) ;
398399 if let Some ( v) = cache. impls . get ( & did) {
399400 let mut used_links = FxHashSet :: default ( ) ;
400401 let mut id_map = IdMap :: new ( ) ;
401402
402403 {
403404 let used_links_bor = & mut used_links;
404- assoc_consts . extend (
405- v . iter ( )
406- . filter ( |i| i . inner_impl ( ) . trait_ . is_none ( ) )
407- . flat_map ( |i| get_associated_constants ( i . inner_impl ( ) , used_links_bor ) ) ,
408- ) ;
405+ for impl_ in v . iter ( ) . map ( |i| i . inner_impl ( ) ) . filter ( |i| i . trait_ . is_none ( ) ) {
406+ assoc_consts . extend ( get_associated_constants ( impl_ , used_links_bor ) ) ;
407+ assoc_types . extend ( get_associated_types ( impl_ , used_links_bor ) ) ;
408+ methods . extend ( get_methods ( impl_ , false , used_links_bor , false , cx . tcx ( ) ) ) ;
409+ }
409410 // We want links' order to be reproducible so we don't use unstable sort.
410411 assoc_consts. sort ( ) ;
411-
412- #[ rustfmt:: skip] // rustfmt makes the pipeline less readable
413- methods. extend (
414- v. iter ( )
415- . filter ( |i| i. inner_impl ( ) . trait_ . is_none ( ) )
416- . flat_map ( |i| get_methods ( i. inner_impl ( ) , false , used_links_bor, false , cx. tcx ( ) ) ) ,
417- ) ;
418-
419- // We want links' order to be reproducible so we don't use unstable sort.
412+ assoc_types. sort ( ) ;
420413 methods. sort ( ) ;
421414 }
422415
@@ -443,15 +436,24 @@ fn sidebar_assoc_items<'a>(
443436 let ( blanket_impl, concrete) : ( Vec < & Impl > , Vec < & Impl > ) =
444437 concrete. into_iter ( ) . partition :: < Vec < _ > , _ > ( |i| i. inner_impl ( ) . kind . is_blanket ( ) ) ;
445438
446- sidebar_render_assoc_items (
447- cx,
448- & mut id_map,
449- concrete,
450- synthetic,
451- blanket_impl,
452- & mut blocks,
453- ) ;
439+ sidebar_render_assoc_items ( cx, & mut id_map, concrete, synthetic, blanket_impl, & mut blocks) ;
454440 }
441+
442+ blocks. extend ( [
443+ LinkBlock :: new (
444+ Link :: new ( "implementations" , "Associated Constants" ) ,
445+ "associatedconstant" ,
446+ assoc_consts,
447+ ) ,
448+ LinkBlock :: new (
449+ Link :: new ( "implementations" , "Associated Types" ) ,
450+ "associatedtype" ,
451+ assoc_types,
452+ ) ,
453+ LinkBlock :: new ( Link :: new ( "implementations" , "Methods" ) , "method" , methods) ,
454+ ] ) ;
455+ blocks. append ( & mut deref_methods) ;
456+ blocks. extend ( [ concrete, synthetic, blanket] ) ;
455457 links. append ( & mut blocks) ;
456458 }
457459}
@@ -715,3 +717,19 @@ fn get_associated_constants<'a>(
715717 } )
716718 . collect :: < Vec < _ > > ( )
717719}
720+
721+ fn get_associated_types < ' a > (
722+ i : & ' a clean:: Impl ,
723+ used_links : & mut FxHashSet < String > ,
724+ ) -> Vec < Link < ' a > > {
725+ i. items
726+ . iter ( )
727+ . filter_map ( |item| match item. name {
728+ Some ( ref name) if !name. is_empty ( ) && item. is_associated_type ( ) => Some ( Link :: new (
729+ get_next_url ( used_links, format ! ( "{typ}.{name}" , typ = ItemType :: AssocType ) ) ,
730+ name. as_str ( ) ,
731+ ) ) ,
732+ _ => None ,
733+ } )
734+ . collect :: < Vec < _ > > ( )
735+ }
0 commit comments