@@ -1107,10 +1107,7 @@ fn clean_function<'tcx>(
1107
1107
clean_args_from_types_and_names ( cx, sig. decl . inputs , names)
1108
1108
}
1109
1109
} ;
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) ;
1114
1111
( generics, decl)
1115
1112
} ) ;
1116
1113
Box :: new ( Function { decl, generics } )
@@ -1161,12 +1158,16 @@ fn clean_args_from_types_and_body_id<'tcx>(
1161
1158
fn clean_fn_decl_with_args < ' tcx > (
1162
1159
cx : & mut DocContext < ' tcx > ,
1163
1160
decl : & hir:: FnDecl < ' tcx > ,
1161
+ header : Option < & hir:: FnHeader > ,
1164
1162
args : Arguments ,
1165
1163
) -> FnDecl {
1166
- let output = match decl. output {
1164
+ let mut output = match decl. output {
1167
1165
hir:: FnRetTy :: Return ( typ) => clean_ty ( typ, cx) ,
1168
1166
hir:: FnRetTy :: DefaultReturn ( ..) => Type :: Tuple ( Vec :: new ( ) ) ,
1169
1167
} ;
1168
+ if let Some ( header) = header && header. is_async ( ) {
1169
+ output = output. sugared_async_return_type ( ) ;
1170
+ }
1170
1171
FnDecl { inputs : args, output, c_variadic : decl. c_variadic }
1171
1172
}
1172
1173
@@ -1179,7 +1180,11 @@ fn clean_fn_decl_from_did_and_sig<'tcx>(
1179
1180
1180
1181
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
1181
1182
// 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
+ }
1183
1188
1184
1189
FnDecl {
1185
1190
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