@@ -607,25 +607,18 @@ impl TypeAliasPart {
607607 let cx = type_impl_collector.cx;
608608 let aliased_types = type_impl_collector.aliased_types;
609609 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;
620613 // render_impl will filter out "impossible-to-call" methods
621614 // to make that functionality work here, it needs to be called with
622615 // each type alias, and if it gives a different result, split the impl
623616 for &(type_alias_fqp, type_alias_item) in type_aliases {
624617 cx.id_map.borrow_mut().clear();
625618 cx.deref_id_map.borrow_mut().clear();
626619 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);
629622 } else {
630623 let target_did = impl_
631624 .inner_impl()
@@ -660,16 +653,22 @@ impl TypeAliasPart {
660653 },
661654 )
662655 .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 {
664663 text,
665- trait_: trait_.clone() ,
664+ trait_,
666665 aliases: vec![type_alias_fqp],
667666 })
668667 }
669668 }
670669 ret
671- })
672- .collect::<Vec<_>>( );
670+ },
671+ );
673672
674673 let mut path = PathBuf::from("type.impl");
675674 for component in &aliased_type.target_fqp[..aliased_type.target_fqp.len() - 1] {
@@ -682,7 +681,7 @@ impl TypeAliasPart {
682681 ));
683682
684683 let part = OrderedJson::array_sorted(
685- impls.iter(). map(OrderedJson::serialize).collect::<Result<Vec<_>, _>>( ).unwrap(),
684+ impls.map(|impl_| OrderedJson::serialize(impl_ ).unwrap() ),
686685 );
687686 path_parts.push(path, OrderedJson::array_unsorted([crate_name_json, &part]));
688687 }
0 commit comments