@@ -1774,25 +1774,26 @@ impl<'tcx> Clean<'tcx, Constant> for ty::Const<'tcx> {
17741774 }
17751775}
17761776
1777- impl < ' tcx > Clean < ' tcx , Item > for hir:: FieldDef < ' tcx > {
1778- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
1779- let def_id = cx. tcx . hir ( ) . local_def_id ( self . hir_id ) . to_def_id ( ) ;
1780- clean_field ( def_id, self . ident . name , clean_ty ( self . ty , cx) , cx)
1781- }
1777+ pub ( crate ) fn clean_field < ' tcx > ( field : & hir:: FieldDef < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Item {
1778+ let def_id = cx. tcx . hir ( ) . local_def_id ( field. hir_id ) . to_def_id ( ) ;
1779+ clean_field_with_def_id ( def_id, field. ident . name , clean_ty ( field. ty , cx) , cx)
17821780}
17831781
1784- impl < ' tcx > Clean < ' tcx , Item > for ty:: FieldDef {
1785- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
1786- clean_field (
1787- self . did ,
1788- self . name ,
1789- clean_middle_ty ( cx. tcx . type_of ( self . did ) , cx, Some ( self . did ) ) ,
1790- cx,
1791- )
1792- }
1782+ pub ( crate ) fn clean_middle_field < ' tcx > ( field : & ty:: FieldDef , cx : & mut DocContext < ' tcx > ) -> Item {
1783+ clean_field_with_def_id (
1784+ field. did ,
1785+ field. name ,
1786+ clean_middle_ty ( cx. tcx . type_of ( field. did ) , cx, Some ( field. did ) ) ,
1787+ cx,
1788+ )
17931789}
17941790
1795- fn clean_field ( def_id : DefId , name : Symbol , ty : Type , cx : & mut DocContext < ' _ > ) -> Item {
1791+ pub ( crate ) fn clean_field_with_def_id (
1792+ def_id : DefId ,
1793+ name : Symbol ,
1794+ ty : Type ,
1795+ cx : & mut DocContext < ' _ > ,
1796+ ) -> Item {
17961797 let what_rustc_thinks =
17971798 Item :: from_def_id_and_parts ( def_id, Some ( name) , StructFieldItem ( ty) , cx) ;
17981799 if is_field_vis_inherited ( cx. tcx , def_id) {
@@ -1830,27 +1831,27 @@ impl<'tcx> Clean<'tcx, VariantStruct> for rustc_hir::VariantData<'tcx> {
18301831 fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> VariantStruct {
18311832 VariantStruct {
18321833 struct_type : CtorKind :: from_hir ( self ) ,
1833- fields : self . fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1834+ fields : self . fields ( ) . iter ( ) . map ( |x| clean_field ( x , cx) ) . collect ( ) ,
18341835 }
18351836 }
18361837}
18371838
18381839impl < ' tcx > Clean < ' tcx , Vec < Item > > for hir:: VariantData < ' tcx > {
18391840 fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Vec < Item > {
1840- self . fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( )
1841+ self . fields ( ) . iter ( ) . map ( |x| clean_field ( x , cx) ) . collect ( )
18411842 }
18421843}
18431844
18441845impl < ' tcx > Clean < ' tcx , Item > for ty:: VariantDef {
18451846 fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Item {
18461847 let kind = match self . ctor_kind {
18471848 CtorKind :: Const => Variant :: CLike ,
1848- CtorKind :: Fn => {
1849- Variant :: Tuple ( self . fields . iter ( ) . map ( |field| field . clean ( cx) ) . collect ( ) )
1850- }
1849+ CtorKind :: Fn => Variant :: Tuple (
1850+ self . fields . iter ( ) . map ( |field| clean_middle_field ( field , cx) ) . collect ( ) ,
1851+ ) ,
18511852 CtorKind :: Fictive => Variant :: Struct ( VariantStruct {
18521853 struct_type : CtorKind :: Fictive ,
1853- fields : self . fields . iter ( ) . map ( |field| field . clean ( cx) ) . collect ( ) ,
1854+ fields : self . fields . iter ( ) . map ( |field| clean_middle_field ( field , cx) ) . collect ( ) ,
18541855 } ) ,
18551856 } ;
18561857 let what_rustc_thinks =
@@ -1970,12 +1971,12 @@ fn clean_maybe_renamed_item<'tcx>(
19701971 } ) ,
19711972 ItemKind :: Union ( ref variant_data, generics) => UnionItem ( Union {
19721973 generics : generics. clean ( cx) ,
1973- fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1974+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| clean_field ( x , cx) ) . collect ( ) ,
19741975 } ) ,
19751976 ItemKind :: Struct ( ref variant_data, generics) => StructItem ( Struct {
19761977 struct_type : CtorKind :: from_hir ( variant_data) ,
19771978 generics : generics. clean ( cx) ,
1978- fields : variant_data. fields ( ) . iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1979+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| clean_field ( x , cx) ) . collect ( ) ,
19791980 } ) ,
19801981 ItemKind :: Impl ( impl_) => return clean_impl ( impl_, item. hir_id ( ) , cx) ,
19811982 // proc macros can have a name set by attributes
0 commit comments