@@ -72,7 +72,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
72
72
let kind = match & e. kind {
73
73
ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
74
74
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 {
76
76
def_id : this. local_def_id ( c. id ) ,
77
77
hir_id : this. lower_node_id ( c. id ) ,
78
78
body : this. lower_const_body ( c. value . span , Some ( & c. value ) ) ,
@@ -189,7 +189,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
189
189
None ,
190
190
e. span ,
191
191
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) ) ,
193
193
) ,
194
194
ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
195
195
ExprKind :: Closure ( box Closure {
@@ -323,7 +323,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
323
323
None ,
324
324
e. span ,
325
325
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) ) ,
327
327
) ,
328
328
ExprKind :: Yield ( opt_expr) => self . lower_expr_yield ( e. span , opt_expr. as_deref ( ) ) ,
329
329
ExprKind :: Err => hir:: ExprKind :: Err (
@@ -350,30 +350,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
350
350
}
351
351
}
352
352
353
- fn lower_binop ( & mut self , b : BinOp ) -> hir:: BinOp {
354
- Spanned {
355
- node : match b. node {
356
- BinOpKind :: Add => hir:: BinOpKind :: Add ,
357
- BinOpKind :: Sub => hir:: BinOpKind :: Sub ,
358
- BinOpKind :: Mul => hir:: BinOpKind :: Mul ,
359
- BinOpKind :: Div => hir:: BinOpKind :: Div ,
360
- BinOpKind :: Rem => hir:: BinOpKind :: Rem ,
361
- BinOpKind :: And => hir:: BinOpKind :: And ,
362
- BinOpKind :: Or => hir:: BinOpKind :: Or ,
363
- BinOpKind :: BitXor => hir:: BinOpKind :: BitXor ,
364
- BinOpKind :: BitAnd => hir:: BinOpKind :: BitAnd ,
365
- BinOpKind :: BitOr => hir:: BinOpKind :: BitOr ,
366
- BinOpKind :: Shl => hir:: BinOpKind :: Shl ,
367
- BinOpKind :: Shr => hir:: BinOpKind :: Shr ,
368
- BinOpKind :: Eq => hir:: BinOpKind :: Eq ,
369
- BinOpKind :: Lt => hir:: BinOpKind :: Lt ,
370
- BinOpKind :: Le => hir:: BinOpKind :: Le ,
371
- BinOpKind :: Ne => hir:: BinOpKind :: Ne ,
372
- BinOpKind :: Ge => hir:: BinOpKind :: Ge ,
373
- BinOpKind :: Gt => hir:: BinOpKind :: Gt ,
374
- } ,
375
- span : self . lower_span ( b. span ) ,
376
- }
353
+ fn lower_binop ( & mut self , b : BinOp ) -> BinOp {
354
+ Spanned { node : b. node , span : self . lower_span ( b. span ) }
377
355
}
378
356
379
357
fn lower_legacy_const_generics (
@@ -781,10 +759,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
781
759
match self . coroutine_kind {
782
760
Some ( hir:: CoroutineKind :: Async ( _) ) => { }
783
761
Some ( hir:: CoroutineKind :: Coroutine ) | Some ( hir:: CoroutineKind :: Gen ( _) ) | None => {
784
- self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
762
+ return hir :: ExprKind :: Err ( self . tcx . sess . emit_err ( AwaitOnlyInAsyncFnAndBlocks {
785
763
await_kw_span,
786
764
item_span : self . current_item ,
787
- } ) ;
765
+ } ) ) ;
788
766
}
789
767
}
790
768
let span = self . mark_span_with_reason ( DesugaringKind :: Await , await_kw_span, None ) ;
@@ -944,9 +922,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
944
922
) -> hir:: ExprKind < ' hir > {
945
923
let ( binder_clause, generic_params) = self . lower_closure_binder ( binder) ;
946
924
947
- let ( body_id, coroutine_option) = self . with_new_scopes ( move |this| {
948
- let prev = this. current_item ;
949
- this. current_item = Some ( fn_decl_span) ;
925
+ let ( body_id, coroutine_option) = self . with_new_scopes ( fn_decl_span, move |this| {
950
926
let mut coroutine_kind = None ;
951
927
let body_id = this. lower_fn_body ( decl, |this| {
952
928
let e = this. lower_expr_mut ( body) ;
@@ -955,7 +931,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
955
931
} ) ;
956
932
let coroutine_option =
957
933
this. coroutine_movability_for_fn ( decl, fn_decl_span, coroutine_kind, movability) ;
958
- this. current_item = prev;
959
934
( body_id, coroutine_option)
960
935
} ) ;
961
936
@@ -1041,7 +1016,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1041
1016
let outer_decl =
1042
1017
FnDecl { inputs : decl. inputs . clone ( ) , output : FnRetTy :: Default ( fn_decl_span) } ;
1043
1018
1044
- let body = self . with_new_scopes ( |this| {
1019
+ let body = self . with_new_scopes ( fn_decl_span , |this| {
1045
1020
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
1046
1021
if capture_clause == CaptureBy :: Ref && !decl. inputs . is_empty ( ) {
1047
1022
this. tcx . sess . emit_err ( AsyncNonMoveClosureNotSupported { fn_decl_span } ) ;
@@ -1063,7 +1038,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1063
1038
async_ret_ty,
1064
1039
body. span ,
1065
1040
hir:: CoroutineSource :: Closure ,
1066
- |this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
1041
+ |this| this. with_new_scopes ( fn_decl_span , |this| this. lower_expr_mut ( body) ) ,
1067
1042
) ;
1068
1043
let hir_id = this. lower_node_id ( inner_closure_id) ;
1069
1044
this. maybe_forward_track_caller ( body. span , closure_hir_id, hir_id) ;
@@ -1503,7 +1478,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1503
1478
match self . coroutine_kind {
1504
1479
Some ( hir:: CoroutineKind :: Gen ( _) ) => { }
1505
1480
Some ( hir:: CoroutineKind :: Async ( _) ) => {
1506
- self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ;
1481
+ return hir:: ExprKind :: Err (
1482
+ self . tcx . sess . emit_err ( AsyncCoroutinesNotSupported { span } ) ,
1483
+ ) ;
1507
1484
}
1508
1485
Some ( hir:: CoroutineKind :: Coroutine ) | None => {
1509
1486
if !self . tcx . features ( ) . coroutines {
0 commit comments