@@ -880,7 +880,7 @@ fn clean_fn_or_proc_macro<'tcx>(
880880 ProcMacroItem ( ProcMacro { kind, helpers } )
881881 }
882882 None => {
883- let mut func = clean_function ( cx, sig, generics, body_id) ;
883+ let mut func = clean_function ( cx, sig, generics, FunctionArgs :: Body ( body_id) ) ;
884884 clean_fn_decl_legacy_const_generics ( & mut func, attrs) ;
885885 FunctionItem ( func)
886886 }
@@ -917,16 +917,28 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
917917 }
918918}
919919
920+ enum FunctionArgs < ' tcx > {
921+ Body ( hir:: BodyId ) ,
922+ Names ( & ' tcx [ Ident ] ) ,
923+ }
924+
920925fn clean_function < ' tcx > (
921926 cx : & mut DocContext < ' tcx > ,
922927 sig : & hir:: FnSig < ' tcx > ,
923928 generics : & hir:: Generics < ' tcx > ,
924- body_id : hir :: BodyId ,
929+ args : FunctionArgs < ' tcx > ,
925930) -> Box < Function > {
926931 let ( generics, decl) = enter_impl_trait ( cx, |cx| {
927932 // NOTE: generics must be cleaned before args
928933 let generics = clean_generics ( generics, cx) ;
929- let args = clean_args_from_types_and_body_id ( cx, sig. decl . inputs , body_id) ;
934+ let args = match args {
935+ FunctionArgs :: Body ( body_id) => {
936+ clean_args_from_types_and_body_id ( cx, sig. decl . inputs , body_id)
937+ }
938+ FunctionArgs :: Names ( names) => {
939+ clean_args_from_types_and_names ( cx, sig. decl . inputs , names)
940+ }
941+ } ;
930942 let mut decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
931943 if sig. header . is_async ( ) {
932944 decl. output = decl. sugared_async_return_type ( ) ;
@@ -1051,18 +1063,12 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
10511063 ) ,
10521064 hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
10531065 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1054- let m = clean_function ( cx, sig, trait_item. generics , body) ;
1066+ let m = clean_function ( cx, sig, trait_item. generics , FunctionArgs :: Body ( body) ) ;
10551067 MethodItem ( m, None )
10561068 }
10571069 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
1058- let ( generics, decl) = enter_impl_trait ( cx, |cx| {
1059- // NOTE: generics must be cleaned before args
1060- let generics = clean_generics ( trait_item. generics , cx) ;
1061- let args = clean_args_from_types_and_names ( cx, sig. decl . inputs , names) ;
1062- let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1063- ( generics, decl)
1064- } ) ;
1065- TyMethodItem ( Box :: new ( Function { decl, generics } ) )
1070+ let m = clean_function ( cx, sig, trait_item. generics , FunctionArgs :: Names ( names) ) ;
1071+ TyMethodItem ( m)
10661072 }
10671073 hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
10681074 let generics = enter_impl_trait ( cx, |cx| clean_generics ( trait_item. generics , cx) ) ;
@@ -1099,7 +1105,7 @@ pub(crate) fn clean_impl_item<'tcx>(
10991105 AssocConstItem ( clean_ty ( ty, cx) , default)
11001106 }
11011107 hir:: ImplItemKind :: Fn ( ref sig, body) => {
1102- let m = clean_function ( cx, sig, impl_. generics , body) ;
1108+ let m = clean_function ( cx, sig, impl_. generics , FunctionArgs :: Body ( body) ) ;
11031109 let defaultness = cx. tcx . impl_defaultness ( impl_. owner_id ) ;
11041110 MethodItem ( m, Some ( defaultness) )
11051111 }
0 commit comments