@@ -211,6 +211,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
211211 // declaration (decl), not the return types.
212212 let coroutine_kind = header. coroutine_kind ;
213213 let body_id = this. lower_maybe_coroutine_body (
214+ * fn_sig_span,
214215 span,
215216 hir_id,
216217 decl,
@@ -799,6 +800,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
799800 }
800801 AssocItemKind :: Fn ( box Fn { sig, generics, body : Some ( body) , .. } ) => {
801802 let body_id = self . lower_maybe_coroutine_body (
803+ sig. span ,
802804 i. span ,
803805 hir_id,
804806 & sig. decl ,
@@ -915,6 +917,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
915917 ) ,
916918 AssocItemKind :: Fn ( box Fn { sig, generics, body, .. } ) => {
917919 let body_id = self . lower_maybe_coroutine_body (
920+ sig. span ,
918921 i. span ,
919922 hir_id,
920923 & sig. decl ,
@@ -1111,6 +1114,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11111114 /// `gen {}` block as appropriate.
11121115 fn lower_maybe_coroutine_body (
11131116 & mut self ,
1117+ fn_decl_span : Span ,
11141118 span : Span ,
11151119 fn_id : hir:: HirId ,
11161120 decl : & FnDecl ,
@@ -1124,6 +1128,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11241128 let ( parameters, expr) = this. lower_coroutine_body_with_moved_arguments (
11251129 decl,
11261130 |this| this. lower_block_expr ( body) ,
1131+ fn_decl_span,
11271132 body. span ,
11281133 coroutine_kind,
11291134 hir:: CoroutineSource :: Fn ,
@@ -1145,6 +1150,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11451150 & mut self ,
11461151 decl : & FnDecl ,
11471152 lower_body : impl FnOnce ( & mut LoweringContext < ' _ , ' hir > ) -> hir:: Expr < ' hir > ,
1153+ fn_decl_span : Span ,
11481154 body_span : Span ,
11491155 coroutine_kind : CoroutineKind ,
11501156 coroutine_source : hir:: CoroutineSource ,
@@ -1315,13 +1321,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
13151321 } ;
13161322 let closure_id = coroutine_kind. closure_id ( ) ;
13171323
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- } ;
13251324 let coroutine_expr = self . make_desugared_coroutine_expr (
13261325 // The default capture mode here is by-ref. Later on during upvar analysis,
13271326 // we will force the captured arguments to by-move, but for async closures,
@@ -1330,7 +1329,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
13301329 CaptureBy :: Ref ,
13311330 closure_id,
13321331 None ,
1333- span,
1332+ fn_decl_span,
1333+ body_span,
13341334 desugaring_kind,
13351335 coroutine_source,
13361336 mkbody,
0 commit comments