@@ -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| {
@@ -111,10 +115,7 @@ pub(crate) fn try_inline(
111115 clean:: ForeignTypeItem
112116 } )
113117 }
114- // Never inline enum variants but leave them shown as re-exports.
115118 Res :: Def ( DefKind :: Variant , _) => return None ,
116- // Assume that enum variants and struct types are re-exported next to
117- // their constructors.
118119 Res :: Def ( DefKind :: Ctor ( ..) , _) | Res :: SelfCtor ( ..) => return Some ( Vec :: new ( ) ) ,
119120 Res :: Def ( DefKind :: Mod , did) => {
120121 record_extern_fqn ( cx, did, ItemType :: Module ) ;
@@ -251,7 +252,7 @@ pub(crate) fn record_extern_fqn(cx: &mut DocContext<'_>, did: DefId, kind: ItemT
251252 }
252253}
253254
254- pub ( crate ) fn build_external_trait ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Trait {
255+ pub ( crate ) fn build_trait ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: Trait {
255256 let trait_items = cx
256257 . tcx
257258 . associated_items ( did)
@@ -263,11 +264,18 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
263264 let predicates = cx. tcx . predicates_of ( did) ;
264265 let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
265266 let generics = filter_non_trait_generics ( did, generics) ;
266- let ( generics, supertrait_bounds) = separate_supertrait_bounds ( generics) ;
267+ let ( generics, supertrait_bounds) = separate_self_bounds ( generics) ;
267268 clean:: Trait { def_id : did, generics, items : trait_items, bounds : supertrait_bounds }
268269}
269270
270- pub ( crate ) fn build_function ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> Box < clean:: Function > {
271+ fn build_trait_alias ( cx : & mut DocContext < ' _ > , did : DefId ) -> clean:: TraitAlias {
272+ let predicates = cx. tcx . predicates_of ( did) ;
273+ let generics = clean_ty_generics ( cx, cx. tcx . generics_of ( did) , predicates) ;
274+ let ( generics, bounds) = separate_self_bounds ( generics) ;
275+ clean:: TraitAlias { generics, bounds }
276+ }
277+
278+ pub ( super ) fn build_function ( cx : & mut DocContext < ' _ > , def_id : DefId ) -> Box < clean:: Function > {
271279 let sig = cx. tcx . fn_sig ( def_id) . instantiate_identity ( ) ;
272280 // The generics need to be cleaned before the signature.
273281 let mut generics =
@@ -788,12 +796,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
788796 g
789797}
790798
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 > ) {
799+ fn separate_self_bounds ( mut g : clean:: Generics ) -> ( clean:: Generics , Vec < clean:: GenericBound > ) {
797800 let mut ty_bounds = Vec :: new ( ) ;
798801 g. where_predicates . retain ( |pred| match * pred {
799802 clean:: WherePredicate :: BoundPredicate { ty : clean:: SelfTy , ref bounds, .. } => {
@@ -806,22 +809,17 @@ fn separate_supertrait_bounds(
806809}
807810
808811pub ( crate ) fn record_extern_trait ( cx : & mut DocContext < ' _ > , did : DefId ) {
809- if did. is_local ( ) {
810- return ;
811- }
812-
812+ if did. is_local ( )
813+ || cx. external_traits . contains_key ( & did)
814+ || cx. active_extern_traits . contains ( & did)
813815 {
814- if cx. external_traits . contains_key ( & did) || cx. active_extern_traits . contains ( & did) {
815- return ;
816- }
816+ return ;
817817 }
818818
819- {
820- cx. active_extern_traits . insert ( did) ;
821- }
819+ cx. active_extern_traits . insert ( did) ;
822820
823821 debug ! ( "record_extern_trait: {did:?}" ) ;
824- let trait_ = build_external_trait ( cx, did) ;
822+ let trait_ = build_trait ( cx, did) ;
825823
826824 cx. external_traits . insert ( did, trait_) ;
827825 cx. active_extern_traits . remove ( & did) ;
0 commit comments