@@ -1016,55 +1016,53 @@ fn clean_poly_trait_ref<'tcx>(
10161016 }
10171017}
10181018
1019- impl < ' tcx > Clean < ' tcx , Item > for hir:: TraitItem < ' tcx > {
1020- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
1021- let local_did = self . def_id . to_def_id ( ) ;
1022- cx. with_param_env ( local_did, |cx| {
1023- let inner = match self . kind {
1024- hir:: TraitItemKind :: Const ( ty, Some ( default) ) => AssocConstItem (
1025- clean_ty ( ty, cx) ,
1026- ConstantKind :: Local { def_id : local_did, body : default } ,
1027- ) ,
1028- hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
1029- hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1030- let m = clean_function ( cx, sig, self . generics , body) ;
1031- MethodItem ( m, None )
1032- }
1033- hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
1034- let ( generics, decl) = enter_impl_trait ( cx, |cx| {
1035- // NOTE: generics must be cleaned before args
1036- let generics = self . generics . clean ( cx) ;
1037- let args = clean_args_from_types_and_names ( cx, sig. decl . inputs , names) ;
1038- let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1039- ( generics, decl)
1040- } ) ;
1041- TyMethodItem ( Box :: new ( Function { decl, generics } ) )
1042- }
1043- hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1044- let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
1045- let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1046- let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1047- AssocTypeItem (
1048- Box :: new ( Typedef {
1049- type_ : clean_ty ( default, cx) ,
1050- generics,
1051- item_type : Some ( item_type) ,
1052- } ) ,
1053- bounds,
1054- )
1055- }
1056- hir:: TraitItemKind :: Type ( bounds, None ) => {
1057- let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
1058- let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1059- TyAssocTypeItem ( Box :: new ( generics) , bounds)
1060- }
1061- } ;
1062- let what_rustc_thinks =
1063- Item :: from_def_id_and_parts ( local_did, Some ( self . ident . name ) , inner, cx) ;
1064- // Trait items always inherit the trait's visibility -- we don't want to show `pub`.
1065- Item { visibility : Inherited , ..what_rustc_thinks }
1066- } )
1067- }
1019+ fn clean_trait_item < ' tcx > ( trait_item : & hir:: TraitItem < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Item {
1020+ let local_did = trait_item. def_id . to_def_id ( ) ;
1021+ cx. with_param_env ( local_did, |cx| {
1022+ let inner = match trait_item. kind {
1023+ hir:: TraitItemKind :: Const ( ty, Some ( default) ) => AssocConstItem (
1024+ clean_ty ( ty, cx) ,
1025+ ConstantKind :: Local { def_id : local_did, body : default } ,
1026+ ) ,
1027+ hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
1028+ hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1029+ let m = clean_function ( cx, sig, trait_item. generics , body) ;
1030+ MethodItem ( m, None )
1031+ }
1032+ hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
1033+ let ( generics, decl) = enter_impl_trait ( cx, |cx| {
1034+ // NOTE: generics must be cleaned before args
1035+ let generics = trait_item. generics . clean ( cx) ;
1036+ let args = clean_args_from_types_and_names ( cx, sig. decl . inputs , names) ;
1037+ let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1038+ ( generics, decl)
1039+ } ) ;
1040+ TyMethodItem ( Box :: new ( Function { decl, generics } ) )
1041+ }
1042+ hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1043+ let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1044+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1045+ let item_type = clean_middle_ty ( hir_ty_to_ty ( cx. tcx , default) , cx, None ) ;
1046+ AssocTypeItem (
1047+ Box :: new ( Typedef {
1048+ type_ : clean_ty ( default, cx) ,
1049+ generics,
1050+ item_type : Some ( item_type) ,
1051+ } ) ,
1052+ bounds,
1053+ )
1054+ }
1055+ hir:: TraitItemKind :: Type ( bounds, None ) => {
1056+ let generics = enter_impl_trait ( cx, |cx| trait_item. generics . clean ( cx) ) ;
1057+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
1058+ TyAssocTypeItem ( Box :: new ( generics) , bounds)
1059+ }
1060+ } ;
1061+ let what_rustc_thinks =
1062+ Item :: from_def_id_and_parts ( local_did, Some ( trait_item. ident . name ) , inner, cx) ;
1063+ // Trait items always inherit the trait's visibility -- we don't want to show `pub`.
1064+ Item { visibility : Inherited , ..what_rustc_thinks }
1065+ } )
10681066}
10691067
10701068impl < ' tcx > Clean < ' tcx , Item > for hir:: ImplItem < ' tcx > {
@@ -1954,8 +1952,10 @@ fn clean_maybe_renamed_item<'tcx>(
19541952 } )
19551953 }
19561954 ItemKind :: Trait ( _, _, generics, bounds, item_ids) => {
1957- let items =
1958- item_ids. iter ( ) . map ( |ti| cx. tcx . hir ( ) . trait_item ( ti. id ) . clean ( cx) ) . collect ( ) ;
1955+ let items = item_ids
1956+ . iter ( )
1957+ . map ( |ti| clean_trait_item ( cx. tcx . hir ( ) . trait_item ( ti. id ) , cx) )
1958+ . collect ( ) ;
19591959
19601960 TraitItem ( Trait {
19611961 def_id,
0 commit comments