@@ -52,7 +52,11 @@ crate trait Clean<T> {
52
52
impl Clean < Item > for DocModule < ' _ > {
53
53
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Item {
54
54
let mut items: Vec < Item > = vec ! [ ] ;
55
- items. extend ( self . foreigns . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
55
+ items. extend (
56
+ self . foreigns
57
+ . iter ( )
58
+ . map ( |( item, renamed) | clean_maybe_renamed_foreign_item ( cx, item, * renamed) ) ,
59
+ ) ;
56
60
items. extend ( self . mods . iter ( ) . map ( |x| x. clean ( cx) ) ) ;
57
61
items. extend (
58
62
self . items
@@ -2030,50 +2034,51 @@ fn clean_use_statement(
2030
2034
vec ! [ Item :: from_def_id_and_parts( import. def_id. to_def_id( ) , None , ImportItem ( inner) , cx) ]
2031
2035
}
2032
2036
2033
- impl Clean < Item > for ( & hir:: ForeignItem < ' _ > , Option < Symbol > ) {
2034
- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Item {
2035
- let ( item, renamed) = self ;
2036
- let def_id = item. def_id . to_def_id ( ) ;
2037
- cx. with_param_env ( def_id, |cx| {
2038
- let kind = match item. kind {
2039
- hir:: ForeignItemKind :: Fn ( decl, names, ref generics) => {
2040
- let abi = cx. tcx . hir ( ) . get_foreign_abi ( item. hir_id ( ) ) ;
2041
- let ( generics, decl) = enter_impl_trait ( cx, |cx| {
2042
- // NOTE: generics must be cleaned before args
2043
- let generics = generics. clean ( cx) ;
2044
- let args = clean_args_from_types_and_names ( cx, decl. inputs , names) ;
2045
- let decl = clean_fn_decl_with_args ( cx, decl, args) ;
2046
- ( generics, decl)
2047
- } ) ;
2048
- ForeignFunctionItem ( Function {
2049
- decl,
2050
- generics,
2051
- header : hir:: FnHeader {
2052
- unsafety : if abi == Abi :: RustIntrinsic {
2053
- intrinsic_operation_unsafety ( item. ident . name )
2054
- } else {
2055
- hir:: Unsafety :: Unsafe
2056
- } ,
2057
- abi,
2058
- constness : hir:: Constness :: NotConst ,
2059
- asyncness : hir:: IsAsync :: NotAsync ,
2037
+ fn clean_maybe_renamed_foreign_item (
2038
+ cx : & mut DocContext < ' _ > ,
2039
+ item : & hir:: ForeignItem < ' _ > ,
2040
+ renamed : Option < Symbol > ,
2041
+ ) -> Item {
2042
+ let def_id = item. def_id . to_def_id ( ) ;
2043
+ cx. with_param_env ( def_id, |cx| {
2044
+ let kind = match item. kind {
2045
+ hir:: ForeignItemKind :: Fn ( decl, names, ref generics) => {
2046
+ let abi = cx. tcx . hir ( ) . get_foreign_abi ( item. hir_id ( ) ) ;
2047
+ let ( generics, decl) = enter_impl_trait ( cx, |cx| {
2048
+ // NOTE: generics must be cleaned before args
2049
+ let generics = generics. clean ( cx) ;
2050
+ let args = clean_args_from_types_and_names ( cx, decl. inputs , names) ;
2051
+ let decl = clean_fn_decl_with_args ( cx, decl, args) ;
2052
+ ( generics, decl)
2053
+ } ) ;
2054
+ ForeignFunctionItem ( Function {
2055
+ decl,
2056
+ generics,
2057
+ header : hir:: FnHeader {
2058
+ unsafety : if abi == Abi :: RustIntrinsic {
2059
+ intrinsic_operation_unsafety ( item. ident . name )
2060
+ } else {
2061
+ hir:: Unsafety :: Unsafe
2060
2062
} ,
2061
- } )
2062
- }
2063
- hir:: ForeignItemKind :: Static ( ref ty, mutability) => {
2064
- ForeignStaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : None } )
2065
- }
2066
- hir:: ForeignItemKind :: Type => ForeignTypeItem ,
2067
- } ;
2063
+ abi,
2064
+ constness : hir:: Constness :: NotConst ,
2065
+ asyncness : hir:: IsAsync :: NotAsync ,
2066
+ } ,
2067
+ } )
2068
+ }
2069
+ hir:: ForeignItemKind :: Static ( ref ty, mutability) => {
2070
+ ForeignStaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : None } )
2071
+ }
2072
+ hir:: ForeignItemKind :: Type => ForeignTypeItem ,
2073
+ } ;
2068
2074
2069
- Item :: from_hir_id_and_parts (
2070
- item. hir_id ( ) ,
2071
- Some ( renamed. unwrap_or ( item. ident . name ) ) ,
2072
- kind,
2073
- cx,
2074
- )
2075
- } )
2076
- }
2075
+ Item :: from_hir_id_and_parts (
2076
+ item. hir_id ( ) ,
2077
+ Some ( renamed. unwrap_or ( item. ident . name ) ) ,
2078
+ kind,
2079
+ cx,
2080
+ )
2081
+ } )
2077
2082
}
2078
2083
2079
2084
impl Clean < TypeBinding > for hir:: TypeBinding < ' _ > {
0 commit comments