@@ -1108,10 +1108,7 @@ fn clean_function<'tcx>(
1108
1108
clean_args_from_types_and_names ( cx, sig. decl . inputs , names)
1109
1109
}
1110
1110
} ;
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) ;
1115
1112
( generics, decl)
1116
1113
} ) ;
1117
1114
Box :: new ( Function { decl, generics } )
@@ -1162,12 +1159,16 @@ fn clean_args_from_types_and_body_id<'tcx>(
1162
1159
fn clean_fn_decl_with_args < ' tcx > (
1163
1160
cx : & mut DocContext < ' tcx > ,
1164
1161
decl : & hir:: FnDecl < ' tcx > ,
1162
+ header : Option < & hir:: FnHeader > ,
1165
1163
args : Arguments ,
1166
1164
) -> FnDecl {
1167
- let output = match decl. output {
1165
+ let mut output = match decl. output {
1168
1166
hir:: FnRetTy :: Return ( typ) => clean_ty ( typ, cx) ,
1169
1167
hir:: FnRetTy :: DefaultReturn ( ..) => Type :: Tuple ( Vec :: new ( ) ) ,
1170
1168
} ;
1169
+ if let Some ( header) = header && header. is_async ( ) {
1170
+ output = output. sugared_async_return_type ( ) ;
1171
+ }
1171
1172
FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
1172
1173
}
1173
1174
@@ -1180,7 +1181,11 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
1180
1181
1181
1182
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
1182
1183
// 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
+ }
1184
1189
1185
1190
FnDecl {
1186
1191
output,
@@ -2566,7 +2571,7 @@ fn clean_bare_fn_ty<'tcx>(
2566
2571
. map ( |x| clean_generic_param ( cx, None , x) )
2567
2572
. collect ( ) ;
2568
2573
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) ;
2570
2575
( generic_params, decl)
2571
2576
} ) ;
2572
2577
BareFunctionDecl { unsafety : bare_fn. unsafety , abi : bare_fn. abi , decl, generic_params }
@@ -3077,7 +3082,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
3077
3082
// NOTE: generics must be cleaned before args
3078
3083
let generics = clean_generics ( generics, cx) ;
3079
3084
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) ;
3081
3086
( generics, decl)
3082
3087
} ) ;
3083
3088
ForeignFunctionItem ( Box :: new ( Function { decl, generics } ) )
0 commit comments