about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-15 19:37:14 +0900
committerGitHub <noreply@github.com>2022-06-15 19:37:14 +0900
commit87e373e82f1791e42d09c1adc9170879304e62cb (patch)
treed563ff456f1b285e0be45b2384e28eb270473317 /compiler/rustc_ast_lowering/src
parent40912e12f1eb35434fc5489adb6ddcb9b976a7e4 (diff)
parent3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac (diff)
downloadrust-87e373e82f1791e42d09c1adc9170879304e62cb.tar.gz
rust-87e373e82f1791e42d09c1adc9170879304e62cb.zip
Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011
Make `ExprKind::Closure` a struct variant.

Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`.

r? ``@Aaron1011``
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/expr.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 3a33a9debaa..0786ae330e0 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -577,7 +577,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         };
 
         // The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`.
-        let decl = self.arena.alloc(hir::FnDecl {
+        let fn_decl = self.arena.alloc(hir::FnDecl {
             inputs: arena_vec![self; input_ty],
             output,
             c_variadic: false,
@@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         };
         let params = arena_vec![self; param];
 
-        let body_id = self.lower_body(move |this| {
+        let body = self.lower_body(move |this| {
             this.generator_kind = Some(hir::GeneratorKind::Async(async_gen_kind));
 
             let old_ctx = this.task_context;
@@ -609,13 +609,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
         });
 
         // `static |_task_context| -> <ret_ty> { body }`:
-        let generator_kind = hir::ExprKind::Closure(
+        let generator_kind = hir::ExprKind::Closure {
             capture_clause,
-            decl,
-            body_id,
-            self.lower_span(span),
-            Some(hir::Movability::Static),
-        );
+            fn_decl,
+            body,
+            fn_decl_span: self.lower_span(span),
+            movability: Some(hir::Movability::Static),
+        };
         let generator = hir::Expr {
             hir_id: self.lower_node_id(closure_node_id),
             kind: generator_kind,
@@ -840,7 +840,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         body: &Expr,
         fn_decl_span: Span,
     ) -> hir::ExprKind<'hir> {
-        let (body_id, generator_option) = self.with_new_scopes(move |this| {
+        let (body, generator_option) = self.with_new_scopes(move |this| {
             let prev = this.current_item;
             this.current_item = Some(fn_decl_span);
             let mut generator_kind = None;
@@ -858,13 +858,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
         // Lower outside new scope to preserve `is_in_loop_condition`.
         let fn_decl = self.lower_fn_decl(decl, None, FnDeclKind::Closure, None);
 
-        hir::ExprKind::Closure(
+        hir::ExprKind::Closure {
             capture_clause,
             fn_decl,
-            body_id,
-            self.lower_span(fn_decl_span),
-            generator_option,
-        )
+            body,
+            fn_decl_span: self.lower_span(fn_decl_span),
+            movability: generator_option,
+        }
     }
 
     fn generator_movability_for_fn(
@@ -911,7 +911,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
         let outer_decl =
             FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
 
-        let body_id = self.with_new_scopes(|this| {
+        let body = self.with_new_scopes(|this| {
             // FIXME(cramertj): allow `async` non-`move` closures with arguments.
             if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
                 struct_span_err!(
@@ -950,13 +950,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
         // closure argument types.
         let fn_decl = self.lower_fn_decl(&outer_decl, None, FnDeclKind::Closure, None);
 
-        hir::ExprKind::Closure(
+        hir::ExprKind::Closure {
             capture_clause,
             fn_decl,
-            body_id,
-            self.lower_span(fn_decl_span),
-            None,
-        )
+            body,
+            fn_decl_span: self.lower_span(fn_decl_span),
+            movability: None,
+        }
     }
 
     /// Destructure the LHS of complex assignments.