@@ -607,25 +607,18 @@ impl TypeAliasPart {
607
607
let cx = type_impl_collector. cx ;
608
608
let aliased_types = type_impl_collector. aliased_types ;
609
609
for aliased_type in aliased_types. values ( ) {
610
- let impls = aliased_type
611
- . impl_
612
- . values ( )
613
- . flat_map ( |AliasedTypeImpl { impl_, type_aliases } | {
614
- let mut ret: Vec < AliasSerializableImpl > = Vec :: new ( ) ;
615
- let trait_ = impl_
616
- . inner_impl ( )
617
- . trait_
618
- . as_ref ( )
619
- . map ( |trait_| format ! ( "{:#}" , trait_. print( cx) ) ) ;
610
+ let impls = aliased_type. impl_ . values ( ) . filter_map (
611
+ |AliasedTypeImpl { impl_, type_aliases } | {
612
+ let mut ret: Option < AliasSerializableImpl > = None ;
620
613
// render_impl will filter out "impossible-to-call" methods
621
614
// to make that functionality work here, it needs to be called with
622
615
// each type alias, and if it gives a different result, split the impl
623
616
for & ( type_alias_fqp, type_alias_item) in type_aliases {
624
617
cx. id_map . borrow_mut ( ) . clear ( ) ;
625
618
cx. deref_id_map . borrow_mut ( ) . clear ( ) ;
626
619
let type_alias_fqp = ( * type_alias_fqp) . iter ( ) . join ( "::" ) ;
627
- if let Some ( last ) = ret. last_mut ( ) {
628
- last . aliases . push ( type_alias_fqp) ;
620
+ if let Some ( ret ) = & mut ret {
621
+ ret . aliases . push ( type_alias_fqp) ;
629
622
} else {
630
623
let target_did = impl_
631
624
. inner_impl ( )
@@ -660,16 +653,22 @@ impl TypeAliasPart {
660
653
} ,
661
654
)
662
655
. to_string ( ) ;
663
- ret. push ( AliasSerializableImpl {
656
+ // The alternate display disables html escaping of '<' and '>'.
657
+ let trait_ = impl_
658
+ . inner_impl ( )
659
+ . trait_
660
+ . as_ref ( )
661
+ . map ( |trait_| format ! ( "{:#}" , trait_. print( cx) ) ) ;
662
+ ret = Some ( AliasSerializableImpl {
664
663
text,
665
- trait_ : trait_ . clone ( ) ,
664
+ trait_,
666
665
aliases : vec ! [ type_alias_fqp] ,
667
666
} )
668
667
}
669
668
}
670
669
ret
671
- } )
672
- . collect :: < Vec < _ > > ( ) ;
670
+ } ,
671
+ ) ;
673
672
674
673
let mut path = PathBuf :: from ( "type.impl" ) ;
675
674
for component in & aliased_type. target_fqp [ ..aliased_type. target_fqp . len ( ) - 1 ] {
@@ -682,7 +681,7 @@ impl TypeAliasPart {
682
681
) ) ;
683
682
684
683
let part = OrderedJson :: array_sorted (
685
- impls. iter ( ) . map ( OrderedJson :: serialize) . collect :: < Result < Vec < _ > , _ > > ( ) . unwrap ( ) ,
684
+ impls. map ( |impl_| OrderedJson :: serialize ( impl_ ) . unwrap ( ) ) ,
686
685
) ;
687
686
path_parts. push ( path, OrderedJson :: array_unsorted ( [ crate_name_json, & part] ) ) ;
688
687
}
0 commit comments