@@ -54,7 +54,11 @@ impl Clean<Item> for DocModule<'_> {
5454 let mut items: Vec < Item > = vec ! [ ] ;
5555 items. extend ( self . foreigns . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
5656 items. extend ( self . mods . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
57- items. extend ( self . items . iter ( ) . map ( |x| x. clean ( cx) ) . flatten ( ) ) ;
57+ items. extend (
58+ self . items
59+ . iter ( )
60+ . flat_map ( |( item, renamed) | clean_maybe_renamed_item ( cx, item, * renamed) ) ,
61+ ) ;
5862
5963 // determine if we should display the inner contents or
6064 // the outer `mod` item for the source code.
@@ -1726,94 +1730,93 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
17261730 }
17271731}
17281732
1729- impl Clean < Vec < Item > > for ( & hir:: Item < ' _ > , Option < Symbol > ) {
1730- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Vec < Item > {
1731- use hir:: ItemKind ;
1732-
1733- let ( item, renamed) = self ;
1734- let def_id = item. def_id . to_def_id ( ) ;
1735- let mut name = renamed. unwrap_or_else ( || cx. tcx . hir ( ) . name ( item. hir_id ( ) ) ) ;
1736- cx. with_param_env ( def_id, |cx| {
1737- let kind = match item. kind {
1738- ItemKind :: Static ( ty, mutability, body_id) => {
1739- StaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : Some ( body_id) } )
1740- }
1741- ItemKind :: Const ( ty, body_id) => ConstantItem ( Constant {
1742- type_ : ty. clean ( cx) ,
1743- kind : ConstantKind :: Local { body : body_id, def_id } ,
1744- } ) ,
1745- ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1746- bounds : ty. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1747- generics : ty. generics . clean ( cx) ,
1748- } ) ,
1749- ItemKind :: TyAlias ( hir_ty, ref generics) => {
1750- let rustdoc_ty = hir_ty. clean ( cx) ;
1751- let ty = hir_ty_to_ty ( cx. tcx , hir_ty) . clean ( cx) ;
1752- TypedefItem (
1753- Typedef {
1754- type_ : rustdoc_ty,
1755- generics : generics. clean ( cx) ,
1756- item_type : Some ( ty) ,
1757- } ,
1758- false ,
1759- )
1760- }
1761- ItemKind :: Enum ( ref def, ref generics) => EnumItem ( Enum {
1762- variants : def. variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
1763- generics : generics. clean ( cx) ,
1764- variants_stripped : false ,
1765- } ) ,
1766- ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
1733+ fn clean_maybe_renamed_item (
1734+ cx : & mut DocContext < ' _ > ,
1735+ item : & hir:: Item < ' _ > ,
1736+ renamed : Option < Symbol > ,
1737+ ) -> Vec < Item > {
1738+ use hir:: ItemKind ;
1739+
1740+ let def_id = item. def_id . to_def_id ( ) ;
1741+ let mut name = renamed. unwrap_or_else ( || cx. tcx . hir ( ) . name ( item. hir_id ( ) ) ) ;
1742+ cx. with_param_env ( def_id, |cx| {
1743+ let kind = match item. kind {
1744+ ItemKind :: Static ( ty, mutability, body_id) => {
1745+ StaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : Some ( body_id) } )
1746+ }
1747+ ItemKind :: Const ( ty, body_id) => ConstantItem ( Constant {
1748+ type_ : ty. clean ( cx) ,
1749+ kind : ConstantKind :: Local { body : body_id, def_id } ,
1750+ } ) ,
1751+ ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
1752+ bounds : ty. bounds . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1753+ generics : ty. generics . clean ( cx) ,
1754+ } ) ,
1755+ ItemKind :: TyAlias ( hir_ty, ref generics) => {
1756+ let rustdoc_ty = hir_ty. clean ( cx) ;
1757+ let ty = hir_ty_to_ty ( cx. tcx , hir_ty) . clean ( cx) ;
1758+ TypedefItem (
1759+ Typedef {
1760+ type_ : rustdoc_ty,
1761+ generics : generics. clean ( cx) ,
1762+ item_type : Some ( ty) ,
1763+ } ,
1764+ false ,
1765+ )
1766+ }
1767+ ItemKind :: Enum ( ref def, ref generics) => EnumItem ( Enum {
1768+ variants : def. variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
1769+ generics : generics. clean ( cx) ,
1770+ variants_stripped : false ,
1771+ } ) ,
1772+ ItemKind :: TraitAlias ( ref generics, bounds) => TraitAliasItem ( TraitAlias {
1773+ generics : generics. clean ( cx) ,
1774+ bounds : bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1775+ } ) ,
1776+ ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
1777+ generics : generics. clean ( cx) ,
1778+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1779+ fields_stripped : false ,
1780+ } ) ,
1781+ ItemKind :: Struct ( ref variant_data, ref generics) => StructItem ( Struct {
1782+ struct_type : CtorKind :: from_hir ( variant_data) ,
1783+ generics : generics. clean ( cx) ,
1784+ fields : variant_data. fields ( ) . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1785+ fields_stripped : false ,
1786+ } ) ,
1787+ ItemKind :: Impl ( ref impl_) => return clean_impl ( impl_, item. hir_id ( ) , cx) ,
1788+ // proc macros can have a name set by attributes
1789+ ItemKind :: Fn ( ref sig, ref generics, body_id) => {
1790+ clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
1791+ }
1792+ ItemKind :: Macro ( ref macro_def) => {
1793+ let ty_vis = cx. tcx . visibility ( def_id) . clean ( cx) ;
1794+ MacroItem ( Macro {
1795+ source : display_macro_source ( cx, name, macro_def, def_id, ty_vis) ,
1796+ } )
1797+ }
1798+ ItemKind :: Trait ( is_auto, unsafety, ref generics, bounds, item_ids) => {
1799+ let items =
1800+ item_ids. iter ( ) . map ( |ti| cx. tcx . hir ( ) . trait_item ( ti. id ) . clean ( cx) ) . collect ( ) ;
1801+ TraitItem ( Trait {
1802+ unsafety,
1803+ items,
17671804 generics : generics. clean ( cx) ,
17681805 bounds : bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1769- } ) ,
1770- ItemKind :: Union ( ref variant_data, ref generics) => UnionItem ( Union {
1771- generics : generics. clean ( cx) ,
1772- fields : variant_data. fields ( ) . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1773- fields_stripped : false ,
1774- } ) ,
1775- ItemKind :: Struct ( ref variant_data, ref generics) => StructItem ( Struct {
1776- struct_type : CtorKind :: from_hir ( variant_data) ,
1777- generics : generics. clean ( cx) ,
1778- fields : variant_data. fields ( ) . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1779- fields_stripped : false ,
1780- } ) ,
1781- ItemKind :: Impl ( ref impl_) => return clean_impl ( impl_, item. hir_id ( ) , cx) ,
1782- // proc macros can have a name set by attributes
1783- ItemKind :: Fn ( ref sig, ref generics, body_id) => {
1784- clean_fn_or_proc_macro ( item, sig, generics, body_id, & mut name, cx)
1785- }
1786- ItemKind :: Macro ( ref macro_def) => {
1787- let ty_vis = cx. tcx . visibility ( def_id) . clean ( cx) ;
1788- MacroItem ( Macro {
1789- source : display_macro_source ( cx, name, macro_def, def_id, ty_vis) ,
1790- } )
1791- }
1792- ItemKind :: Trait ( is_auto, unsafety, ref generics, bounds, item_ids) => {
1793- let items = item_ids
1794- . iter ( )
1795- . map ( |ti| cx. tcx . hir ( ) . trait_item ( ti. id ) . clean ( cx) )
1796- . collect ( ) ;
1797- TraitItem ( Trait {
1798- unsafety,
1799- items,
1800- generics : generics. clean ( cx) ,
1801- bounds : bounds. iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
1802- is_auto : is_auto. clean ( cx) ,
1803- } )
1804- }
1805- ItemKind :: ExternCrate ( orig_name) => {
1806- return clean_extern_crate ( item, name, orig_name, cx) ;
1807- }
1808- ItemKind :: Use ( path, kind) => {
1809- return clean_use_statement ( item, name, path, kind, cx) ;
1810- }
1811- _ => unreachable ! ( "not yet converted" ) ,
1812- } ;
1806+ is_auto : is_auto. clean ( cx) ,
1807+ } )
1808+ }
1809+ ItemKind :: ExternCrate ( orig_name) => {
1810+ return clean_extern_crate ( item, name, orig_name, cx) ;
1811+ }
1812+ ItemKind :: Use ( path, kind) => {
1813+ return clean_use_statement ( item, name, path, kind, cx) ;
1814+ }
1815+ _ => unreachable ! ( "not yet converted" ) ,
1816+ } ;
18131817
1814- vec ! [ Item :: from_def_id_and_parts( def_id, Some ( name) , kind, cx) ]
1815- } )
1816- }
1818+ vec ! [ Item :: from_def_id_and_parts( def_id, Some ( name) , kind, cx) ]
1819+ } )
18171820}
18181821
18191822impl Clean < Item > for hir:: Variant < ' _ > {
0 commit comments