@@ -880,7 +880,7 @@ fn clean_fn_or_proc_macro<'tcx>(
880
880
ProcMacroItem ( ProcMacro { kind, helpers } )
881
881
}
882
882
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) ) ;
884
884
clean_fn_decl_legacy_const_generics ( & mut func, attrs) ;
885
885
FunctionItem ( func)
886
886
}
@@ -917,16 +917,28 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[ast::Attrib
917
917
}
918
918
}
919
919
920
+ enum FunctionArgs < ' tcx > {
921
+ Body ( hir:: BodyId ) ,
922
+ Names ( & ' tcx [ Ident ] ) ,
923
+ }
924
+
920
925
fn clean_function < ' tcx > (
921
926
cx : & mut DocContext < ' tcx > ,
922
927
sig : & hir:: FnSig < ' tcx > ,
923
928
generics : & hir:: Generics < ' tcx > ,
924
- body_id : hir :: BodyId ,
929
+ args : FunctionArgs < ' tcx > ,
925
930
) -> Box < Function > {
926
931
let ( generics, decl) = enter_impl_trait ( cx, |cx| {
927
932
// NOTE: generics must be cleaned before args
928
933
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
+ } ;
930
942
let mut decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
931
943
if sig. header . is_async ( ) {
932
944
decl. output = decl. sugared_async_return_type ( ) ;
@@ -1051,18 +1063,12 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1051
1063
) ,
1052
1064
hir:: TraitItemKind :: Const ( ty, None ) => TyAssocConstItem ( clean_ty ( ty, cx) ) ,
1053
1065
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) ) ;
1055
1067
MethodItem ( m, None )
1056
1068
}
1057
1069
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)
1066
1072
}
1067
1073
hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
1068
1074
let generics = enter_impl_trait ( cx, |cx| clean_generics ( trait_item. generics , cx) ) ;
@@ -1099,7 +1105,7 @@ pub(crate) fn clean_impl_item<'tcx>(
1099
1105
AssocConstItem ( clean_ty ( ty, cx) , default)
1100
1106
}
1101
1107
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) ) ;
1103
1109
let defaultness = cx. tcx . impl_defaultness ( impl_. owner_id ) ;
1104
1110
MethodItem ( m, Some ( defaultness) )
1105
1111
}
0 commit comments