@@ -67,9 +67,13 @@ pub(crate) fn try_inline(
6767 record_extern_fqn ( cx, did, ItemType :: Trait ) ;
6868 cx. with_param_env ( did, |cx| {
6969 build_impls ( cx, did, attrs_without_docs, & mut ret) ;
70- clean:: TraitItem ( Box :: new ( build_external_trait ( cx, did) ) )
70+ clean:: TraitItem ( Box :: new ( build_trait ( cx, did) ) )
7171 } )
7272 }
73+ Res :: Def ( DefKind :: TraitAlias , did) => {
74+ record_extern_fqn ( cx, did, ItemType :: TraitAlias ) ;
75+ cx. with_param_env ( did, |cx| clean:: TraitAliasItem ( build_trait_alias ( cx, did) ) )
76+ }
7377 Res :: Def ( DefKind :: Fn , did) => {
7478 record_extern_fqn ( cx, did, ItemType :: Function ) ;
7579 cx. with_param_env ( did, |cx| {
@@ -251,7 +255,7 @@ pub(crate) fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemT
251255 }
252256}
253257
254- pub ( crate ) fn build_external_trait ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Trait {
258+ pub ( crate ) fn build_trait ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Trait {
255259 let trait_items = cx
256260 . tcx
257261 . associated_items ( did)
@@ -263,11 +267,18 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
263267 let predicates = cx. tcx . predicates_of ( did) ;
264268 let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
265269 let generics = filter_non_trait_generics ( did, generics) ;
266- let ( generics, supertrait_bounds) = separate_supertrait_bounds ( generics) ;
270+ let ( generics, supertrait_bounds) = separate_self_bounds ( generics) ;
267271 clean:: Trait { def_id : did, generics, items : trait_items, bounds : supertrait_bounds }
268272}
269273
270- pub ( crate ) fn build_function ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> Box < clean:: Function > {
274+ fn build_trait_alias ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: TraitAlias {
275+ let predicates = cx. tcx . predicates_of ( did) ;
276+ let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
277+ let ( generics, bounds) = separate_self_bounds ( generics) ;
278+ clean:: TraitAlias { generics, bounds }
279+ }
280+
281+ pub ( super ) fn build_function ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> Box < clean:: Function > {
271282 let sig = cx. tcx . fn_sig ( def_id) . instantiate_identity ( ) ;
272283 // The generics need to be cleaned before the signature.
273284 let mut generics =
@@ -788,12 +799,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
788799 g
789800}
790801
791- /// Supertrait bounds for a trait are also listed in the generics coming from
792- /// the metadata for a crate, so we want to separate those out and create a new
793- /// list of explicit supertrait bounds to render nicely.
794- fn separate_supertrait_bounds (
795- mut g : clean:: Generics ,
796- ) -> ( clean:: Generics , Vec < clean:: GenericBound > ) {
802+ fn separate_self_bounds ( mut g : clean:: Generics ) -> ( clean:: Generics , Vec < clean:: GenericBound > ) {
797803 let mut ty_bounds = Vec :: new ( ) ;
798804 g. where_predicates . retain ( |pred| match * pred {
799805 clean:: WherePredicate :: BoundPredicate { ty : clean:: SelfTy , ref bounds, .. } => {
@@ -806,22 +812,17 @@ fn separate_supertrait_bounds(
806812}
807813
808814pub ( crate ) fn record_extern_trait ( cx : & mut DocContext < ' _ > , did : DefId ) {
809- if did. is_local ( ) {
810- return ;
811- }
812-
815+ if did. is_local ( )
816+ || cx. external_traits . contains_key ( & did)
817+ || cx. active_extern_traits . contains ( & did)
813818 {
814- if cx. external_traits . contains_key ( & did) || cx. active_extern_traits . contains ( & did) {
815- return ;
816- }
819+ return ;
817820 }
818821
819- {
820- cx. active_extern_traits . insert ( did) ;
821- }
822+ cx. active_extern_traits . insert ( did) ;
822823
823824 debug ! ( "record_extern_trait: {did:?}" ) ;
824- let trait_ = build_external_trait ( cx, did) ;
825+ let trait_ = build_trait ( cx, did) ;
825826
826827 cx. external_traits . insert ( did, trait_) ;
827828 cx. active_extern_traits . remove ( & did) ;
0 commit comments