@@ -211,6 +211,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
211
211
// declaration (decl), not the return types.
212
212
let coroutine_kind = header. coroutine_kind ;
213
213
let body_id = this. lower_maybe_coroutine_body (
214
+ * fn_sig_span,
214
215
span,
215
216
hir_id,
216
217
decl,
@@ -799,6 +800,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
799
800
}
800
801
AssocItemKind :: Fn ( box Fn { sig, generics, body : Some ( body) , .. } ) => {
801
802
let body_id = self . lower_maybe_coroutine_body (
803
+ sig. span ,
802
804
i. span ,
803
805
hir_id,
804
806
& sig. decl ,
@@ -915,6 +917,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
915
917
) ,
916
918
AssocItemKind :: Fn ( box Fn { sig, generics, body, .. } ) => {
917
919
let body_id = self . lower_maybe_coroutine_body (
920
+ sig. span ,
918
921
i. span ,
919
922
hir_id,
920
923
& sig. decl ,
@@ -1111,6 +1114,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1111
1114
/// `gen {}` block as appropriate.
1112
1115
fn lower_maybe_coroutine_body (
1113
1116
& mut self ,
1117
+ fn_decl_span : Span ,
1114
1118
span : Span ,
1115
1119
fn_id : hir:: HirId ,
1116
1120
decl : & FnDecl ,
@@ -1124,6 +1128,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1124
1128
let ( parameters, expr) = this. lower_coroutine_body_with_moved_arguments (
1125
1129
decl,
1126
1130
|this| this. lower_block_expr ( body) ,
1131
+ fn_decl_span,
1127
1132
body. span ,
1128
1133
coroutine_kind,
1129
1134
hir:: CoroutineSource :: Fn ,
@@ -1145,6 +1150,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1145
1150
& mut self ,
1146
1151
decl : & FnDecl ,
1147
1152
lower_body : impl FnOnce ( & mut LoweringContext < ' _ , ' hir > ) -> hir:: Expr < ' hir > ,
1153
+ fn_decl_span : Span ,
1148
1154
body_span : Span ,
1149
1155
coroutine_kind : CoroutineKind ,
1150
1156
coroutine_source : hir:: CoroutineSource ,
@@ -1315,13 +1321,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
1315
1321
} ;
1316
1322
let closure_id = coroutine_kind. closure_id ( ) ;
1317
1323
1318
- let span = if let FnRetTy :: Default ( span) = decl. output
1319
- && matches ! ( coroutine_source, rustc_hir:: CoroutineSource :: Closure )
1320
- {
1321
- body_span. with_lo ( span. lo ( ) )
1322
- } else {
1323
- body_span
1324
- } ;
1325
1324
let coroutine_expr = self . make_desugared_coroutine_expr (
1326
1325
// The default capture mode here is by-ref. Later on during upvar analysis,
1327
1326
// we will force the captured arguments to by-move, but for async closures,
@@ -1330,7 +1329,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1330
1329
CaptureBy :: Ref ,
1331
1330
closure_id,
1332
1331
None ,
1333
- span,
1332
+ fn_decl_span,
1333
+ body_span,
1334
1334
desugaring_kind,
1335
1335
coroutine_source,
1336
1336
mkbody,
0 commit comments