@@ -1108,10 +1108,7 @@ fn clean_function<'tcx>(
11081108 clean_args_from_types_and_names ( cx, sig. decl . inputs , names)
11091109 }
11101110 } ;
1111- let mut decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1112- if sig. header . is_async ( ) {
1113- decl. output = decl. sugared_async_return_type ( ) ;
1114- }
1111+ let decl = clean_fn_decl_with_args ( cx, sig. decl , Some ( & sig. header ) , args) ;
11151112 ( generics, decl)
11161113 } ) ;
11171114 Box :: new ( Function { decl, generics } )
@@ -1162,12 +1159,16 @@ fn clean_args_from_types_and_body_id<'tcx>(
11621159fn clean_fn_decl_with_args < ' tcx > (
11631160 cx : & mut DocContext < ' tcx > ,
11641161 decl : & hir:: FnDecl < ' tcx > ,
1162+ header : Option < & hir:: FnHeader > ,
11651163 args : Arguments ,
11661164) -> FnDecl {
1167- let output = match decl. output {
1165+ let mut output = match decl. output {
11681166 hir:: FnRetTy :: Return ( typ) => clean_ty ( typ, cx) ,
11691167 hir:: FnRetTy :: DefaultReturn ( ..) => Type :: Tuple ( Vec :: new ( ) ) ,
11701168 } ;
1169+ if let Some ( header) = header && header. is_async ( ) {
1170+ output = output. sugared_async_return_type ( ) ;
1171+ }
11711172 FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
11721173}
11731174
@@ -1180,7 +1181,11 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
11801181
11811182 // We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
11821183 // but shouldn't change any code meaning.
1183- let output = clean_middle_ty ( sig. output ( ) , cx, None , None ) ;
1184+ let mut output = clean_middle_ty ( sig. output ( ) , cx, None , None ) ;
1185+
1186+ if let Some ( did) = did && cx. tcx . asyncness ( did) . is_async ( ) {
1187+ output = output. sugared_async_return_type ( ) ;
1188+ }
11841189
11851190 FnDecl {
11861191 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