@@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
7272 let kind = match & e. kind {
7373 ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
7474 ExprKind :: ConstBlock ( c) => {
75- let c = self . with_new_scopes ( |this| hir:: ConstBlock {
75+ let c = self . with_new_scopes ( c . value . span , |this| hir:: ConstBlock {
7676 def_id : this. local_def_id ( c. id ) ,
7777 hir_id : this. lower_node_id ( c. id ) ,
7878 body : this. lower_const_body ( c. value . span , Some ( & c. value ) ) ,
@@ -189,7 +189,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
189189 None ,
190190 e. span ,
191191 hir:: CoroutineSource :: Block ,
192- |this| this. with_new_scopes ( |this| this. lower_block_expr ( block) ) ,
192+ |this| this. with_new_scopes ( e . span , |this| this. lower_block_expr ( block) ) ,
193193 ) ,
194194 ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
195195 ExprKind :: Closure ( box Closure {
@@ -323,7 +323,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
323323 None ,
324324 e. span ,
325325 hir:: CoroutineSource :: Block ,
326- |this| this. with_new_scopes ( |this| this. lower_block_expr ( block) ) ,
326+ |this| this. with_new_scopes ( e . span , |this| this. lower_block_expr ( block) ) ,
327327 ) ,
328328 ExprKind :: Yield ( opt_expr) => self . lower_expr_yield ( e. span , opt_expr. as_deref ( ) ) ,
329329 ExprKind :: Err => hir:: ExprKind :: Err (
@@ -941,9 +941,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
941941 ) -> hir:: ExprKind < ' hir > {
942942 let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
943943
944- let ( body_id, coroutine_option) = self . with_new_scopes ( move |this| {
945- let prev = this. current_item ;
946- this. current_item = Some ( fn_decl_span) ;
944+ let ( body_id, coroutine_option) = self . with_new_scopes ( fn_decl_span, move |this| {
947945 let mut coroutine_kind = None ;
948946 let body_id = this. lower_fn_body ( decl, |this| {
949947 let e = this. lower_expr_mut ( body) ;
@@ -952,7 +950,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
952950 } ) ;
953951 let coroutine_option =
954952 this. coroutine_movability_for_fn ( decl, fn_decl_span, coroutine_kind, movability) ;
955- this. current_item = prev;
956953 ( body_id, coroutine_option)
957954 } ) ;
958955
@@ -1038,7 +1035,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10381035 let outer_decl =
10391036 FnDecl { inputs : decl. inputs . clone ( ) , output : FnRetTy :: Default ( fn_decl_span) } ;
10401037
1041- let body = self . with_new_scopes ( |this| {
1038+ let body = self . with_new_scopes ( fn_decl_span , |this| {
10421039 // FIXME(cramertj): allow `async` non-`move` closures with arguments.
10431040 if capture_clause == CaptureBy :: Ref && !decl. inputs . is_empty ( ) {
10441041 this. tcx . sess . emit_err ( AsyncNonMoveClosureNotSupported { fn_decl_span } ) ;
@@ -1060,7 +1057,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10601057 async_ret_ty,
10611058 body. span ,
10621059 hir:: CoroutineSource :: Closure ,
1063- |this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
1060+ |this| this. with_new_scopes ( fn_decl_span , |this| this. lower_expr_mut ( body) ) ,
10641061 ) ;
10651062 let hir_id = this. lower_node_id ( inner_closure_id) ;
10661063 this. maybe_forward_track_caller ( body. span , closure_hir_id, hir_id) ;
@@ -1500,7 +1497,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
15001497 match self . coroutine_kind {
15011498 Some ( hir:: CoroutineKind :: Gen ( _) ) => { }
15021499 Some ( hir:: CoroutineKind :: Async ( _) ) => {
1503- return hir:: ExprKind :: Err ( self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ) ;
1500+ return hir:: ExprKind :: Err (
1501+ self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ,
1502+ ) ;
15041503 }
15051504 Some ( hir:: CoroutineKind :: Coroutine ) | None => {
15061505 if !self . tcx . features ( ) . coroutines {
0 commit comments