@@ -620,6 +620,39 @@ fn sidebar_render_assoc_items(
620
620
blanket_impl : Vec < & Impl > ,
621
621
items : & mut Vec < LinkBlock < ' _ > > ,
622
622
) {
623
+ let format_concrete_impls = |impls : Vec < & Impl > , id_map : & mut IdMap | {
624
+ let mut links = FxHashSet :: default ( ) ;
625
+
626
+ let ( locals, externals) : ( Vec < ( Link < ' static > , bool ) > , Vec < ( Link < ' static > , bool ) > ) = impls
627
+ . iter ( )
628
+ . filter_map ( |it| {
629
+ let trait_ = it. inner_impl ( ) . trait_ . as_ref ( ) ?;
630
+
631
+ let encoded = id_map. derive ( super :: get_id_for_impl ( cx. tcx ( ) , it. impl_item . item_id ) ) ;
632
+
633
+ let prefix = match it. inner_impl ( ) . polarity {
634
+ ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
635
+ ty:: ImplPolarity :: Negative => "!" ,
636
+ } ;
637
+ let generated = Link :: new ( encoded, format ! ( "{prefix}{:#}" , trait_. print( cx) ) ) ;
638
+ if links. insert ( generated. clone ( ) ) {
639
+ Some ( ( generated, trait_. res . def_id ( ) . is_local ( ) ) )
640
+ } else {
641
+ None
642
+ }
643
+ } )
644
+ . partition ( |elem| elem. 1 ) ;
645
+
646
+ let mut locals = locals. into_iter ( ) . map ( |elem| elem. 0 ) . collect :: < Vec < Link < ' static > > > ( ) ;
647
+ locals. sort ( ) ;
648
+
649
+ let mut externals =
650
+ externals. into_iter ( ) . map ( |elem| elem. 0 ) . collect :: < Vec < Link < ' static > > > ( ) ;
651
+ externals. sort ( ) ;
652
+
653
+ ( locals, externals)
654
+ } ;
655
+
623
656
let format_impls = |impls : Vec < & Impl > , id_map : & mut IdMap | {
624
657
let mut links = FxHashSet :: default ( ) ;
625
658
@@ -641,14 +674,19 @@ fn sidebar_render_assoc_items(
641
674
ret
642
675
} ;
643
676
644
- let concrete = format_impls ( concrete, id_map) ;
677
+ let ( concrete_locals , concrete_externals ) = format_concrete_impls ( concrete, id_map) ;
645
678
let synthetic = format_impls ( synthetic, id_map) ;
646
679
let blanket = format_impls ( blanket_impl, id_map) ;
647
680
items. extend ( [
648
681
LinkBlock :: new (
649
- Link :: new ( "trait-implementations" , "Trait Implementations" ) ,
682
+ Link :: new ( "crate-trait-implementations" , "Crate Trait Implementations" ) ,
683
+ "trait-implementation" ,
684
+ concrete_locals,
685
+ ) ,
686
+ LinkBlock :: new (
687
+ Link :: new ( "external-trait-implementations" , "External Trait Implementations" ) ,
650
688
"trait-implementation" ,
651
- concrete ,
689
+ concrete_externals ,
652
690
) ,
653
691
LinkBlock :: new (
654
692
Link :: new ( "synthetic-implementations" , "Auto Trait Implementations" ) ,
0 commit comments