@@ -251,10 +251,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
251251 ExprKind :: Await ( expr, await_kw_span) => self . lower_expr_await ( * await_kw_span, expr) ,
252252 ExprKind :: Move ( _, move_kw_span) => {
253253 if !self . tcx . features ( ) . move_expr ( ) {
254- return self . expr_err (
255- * move_kw_span,
256- self . dcx ( ) . span_delayed_bug ( * move_kw_span, "invalid move(expr)" ) ,
257- ) ;
254+ return self . expr_err ( * move_kw_span, self . dcx ( ) . has_errors ( ) . unwrap ( ) ) ;
258255 }
259256 if let Some ( ( ident, binding) ) = self
260257 . move_expr_bindings
@@ -277,10 +274,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
277274 } ) ,
278275 ) )
279276 } else {
280- self . dcx ( ) . emit_err ( MoveExprOnlyInPlainClosures { span : * move_kw_span } ) ;
281- hir :: ExprKind :: Err (
282- self . dcx ( ) . span_delayed_bug ( * move_kw_span, "invalid move(expr)" ) ,
283- )
277+ let guar = self
278+ . dcx ( )
279+ . emit_err ( MoveExprOnlyInPlainClosures { span : * move_kw_span } ) ;
280+ hir :: ExprKind :: Err ( guar )
284281 }
285282 }
286283 ExprKind :: Use ( expr, use_kw_span) => self . lower_expr_use ( * use_kw_span, expr) ,
@@ -1096,6 +1093,8 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
10961093 let attrs = self . lower_attrs ( expr_hir_id, & e. attrs , e. span , Target :: from_expr ( e) ) ;
10971094
10981095 match closure. coroutine_kind {
1096+ // FIXME(TaKO8Ki): Support `move(expr)` in coroutine closures too.
1097+ // For the first step, we only support plain closures.
10991098 Some ( coroutine_kind) => hir:: Expr {
11001099 hir_id : expr_hir_id,
11011100 kind : self . lower_expr_coroutine_closure (
@@ -1188,12 +1187,11 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
11881187 ) ) ;
11891188 }
11901189
1191- let explicit_captures = self . arena . alloc_from_iter ( lowered_occurrences. iter ( ) . map (
1192- |( occurrence, _, binding) | hir:: ExplicitCapture {
1193- var_hir_id : * binding,
1194- origin_span : self . lower_span ( occurrence. move_kw_span ) ,
1195- } ,
1196- ) ) ;
1190+ let explicit_captures = self . arena . alloc_from_iter (
1191+ lowered_occurrences
1192+ . iter ( )
1193+ . map ( |( _, _, binding) | hir:: ExplicitCapture { var_hir_id : * binding } ) ,
1194+ ) ;
11971195
11981196 let closure_expr = self . arena . alloc ( hir:: Expr {
11991197 hir_id : expr_hir_id,
@@ -1395,9 +1393,10 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
13951393 // knows that a `FnDecl` output type like `-> &str` actually means
13961394 // "coroutine that returns &str", rather than directly returning a `&str`.
13971395 kind : hir:: ClosureKind :: CoroutineClosure ( coroutine_desugaring) ,
1398- constness : hir :: Constness :: NotConst ,
1396+ constness : self . lower_constness ( constness ) ,
13991397 explicit_captures : & [ ] ,
14001398 } ) ;
1399+
14011400 hir:: ExprKind :: Closure ( c)
14021401 }
14031402
0 commit comments