@@ -1107,10 +1107,7 @@ fn clean_function<'tcx>(
11071107 clean_args_from_types_and_names ( cx, sig. decl . inputs , names)
11081108 }
11091109 } ;
1110- let mut decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1111- if sig. header . is_async ( ) {
1112- decl. output = decl. sugared_async_return_type ( ) ;
1113- }
1110+ let decl = clean_fn_decl_with_args ( cx, sig. decl , Some ( & sig. header ) , args) ;
11141111 ( generics, decl)
11151112 } ) ;
11161113 Box :: new ( Function { decl, generics } )
@@ -1161,12 +1158,16 @@ fn clean_args_from_types_and_body_id<'tcx>(
11611158fn clean_fn_decl_with_args < ' tcx > (
11621159 cx : & mut DocContext < ' tcx > ,
11631160 decl : & hir:: FnDecl < ' tcx > ,
1161+ header : Option < & hir:: FnHeader > ,
11641162 args : Arguments ,
11651163) -> FnDecl {
1166- let output = match decl. output {
1164+ let mut output = match decl. output {
11671165 hir:: FnRetTy :: Return ( typ) => clean_ty ( typ, cx) ,
11681166 hir:: FnRetTy :: DefaultReturn ( ..) => Type :: Tuple ( Vec :: new ( ) ) ,
11691167 } ;
1168+ if let Some ( header) = header && header. is_async ( ) {
1169+ output = output. sugared_async_return_type ( ) ;
1170+ }
11701171 FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
11711172}
11721173
@@ -1179,7 +1180,11 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
11791180
11801181 // We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
11811182 // but shouldn't change any code meaning.
1182- let output = clean_middle_ty ( sig. output ( ) , cx, None , None ) ;
1183+ let mut output = clean_middle_ty ( sig. output ( ) , cx, None , None ) ;
1184+
1185+ if let Some ( did) = did && cx. tcx . asyncness ( did) . is_async ( ) {
1186+ output = output. sugared_async_return_type ( ) ;
1187+ }
11831188
11841189 FnDecl {
11851190 output,
@@ -2566,7 +2571,7 @@ fn clean_bare_fn_ty<'tcx>(
25662571 . map ( |x| clean_generic_param ( cx, None , x) )
25672572 . collect ( ) ;
25682573 let args = clean_args_from_types_and_names ( cx, bare_fn. decl . inputs , bare_fn. param_names ) ;
2569- let decl = clean_fn_decl_with_args ( cx, bare_fn. decl , args) ;
2574+ let decl = clean_fn_decl_with_args ( cx, bare_fn. decl , None , args) ;
25702575 ( generic_params, decl)
25712576 } ) ;
25722577 BareFunctionDecl { unsafety : bare_fn. unsafety , abi : bare_fn. abi , decl, generic_params }
@@ -3077,7 +3082,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
30773082 // NOTE: generics must be cleaned before args
30783083 let generics = clean_generics ( generics, cx) ;
30793084 let args = clean_args_from_types_and_names ( cx, decl. inputs , names) ;
3080- let decl = clean_fn_decl_with_args ( cx, decl, args) ;
3085+ let decl = clean_fn_decl_with_args ( cx, decl, None , args) ;
30813086 ( generics, decl)
30823087 } ) ;
30833088 ForeignFunctionItem ( Box :: new ( Function { decl, generics } ) )
0 commit comments