@@ -394,29 +394,22 @@ fn sidebar_assoc_items<'a>(
394
394
let cache = cx. cache ( ) ;
395
395
396
396
let mut assoc_consts = Vec :: new ( ) ;
397
+ let mut assoc_types = Vec :: new ( ) ;
397
398
let mut methods = Vec :: new ( ) ;
398
399
if let Some ( v) = cache. impls . get ( & did) {
399
400
let mut used_links = FxHashSet :: default ( ) ;
400
401
let mut id_map = IdMap :: new ( ) ;
401
402
402
403
{
403
404
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
+ }
409
410
// We want links' order to be reproducible so we don't use unstable sort.
410
411
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 ( ) ;
420
413
methods. sort ( ) ;
421
414
}
422
415
@@ -443,15 +436,24 @@ fn sidebar_assoc_items<'a>(
443
436
let ( blanket_impl, concrete) : ( Vec < & Impl > , Vec < & Impl > ) =
444
437
concrete. into_iter ( ) . partition :: < Vec < _ > , _ > ( |i| i. inner_impl ( ) . kind . is_blanket ( ) ) ;
445
438
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) ;
454
440
}
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] ) ;
455
457
links. append ( & mut blocks) ;
456
458
}
457
459
}
@@ -715,3 +717,19 @@ fn get_associated_constants<'a>(
715
717
} )
716
718
. collect :: < Vec < _ > > ( )
717
719
}
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