diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-11 21:25:25 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-06-12 00:16:27 +0200 |
| commit | 3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac (patch) | |
| tree | 66c3a317d49d7fb64829d951b6d38f4b8ffff2ec /compiler/rustc_hir/src | |
| parent | fa68e73e9947be8ffc5b3b46d899e4953a44e7e9 (diff) | |
| download | rust-3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac.tar.gz rust-3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac.zip | |
Make `ExprKind::Closure` a struct variant.
Diffstat (limited to 'compiler/rustc_hir/src')
| -rw-r--r-- | compiler/rustc_hir/src/hir.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_hir/src/intravisit.rs | 15 |
2 files changed, 18 insertions, 13 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 2f5f271dc50..60f8bb51d65 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1651,7 +1651,7 @@ impl Expr<'_> { ExprKind::Let(..) => ExprPrecedence::Let, ExprKind::Loop(..) => ExprPrecedence::Loop, ExprKind::Match(..) => ExprPrecedence::Match, - ExprKind::Closure(..) => ExprPrecedence::Closure, + ExprKind::Closure { .. } => ExprPrecedence::Closure, ExprKind::Block(..) => ExprPrecedence::Block, ExprKind::Assign(..) => ExprPrecedence::Assign, ExprKind::AssignOp(..) => ExprPrecedence::AssignOp, @@ -1711,7 +1711,7 @@ impl Expr<'_> { | ExprKind::Tup(..) | ExprKind::If(..) | ExprKind::Match(..) - | ExprKind::Closure(..) + | ExprKind::Closure { .. } | ExprKind::Block(..) | ExprKind::Repeat(..) | ExprKind::Array(..) @@ -1794,7 +1794,7 @@ impl Expr<'_> { | ExprKind::Match(..) | ExprKind::MethodCall(..) | ExprKind::Call(..) - | ExprKind::Closure(..) + | ExprKind::Closure { .. } | ExprKind::Block(..) | ExprKind::Repeat(..) | ExprKind::Break(..) @@ -1929,7 +1929,13 @@ pub enum ExprKind<'hir> { /// /// This may also be a generator literal or an `async block` as indicated by the /// `Option<Movability>`. - Closure(CaptureBy, &'hir FnDecl<'hir>, BodyId, Span, Option<Movability>), + Closure { + capture_clause: CaptureBy, + fn_decl: &'hir FnDecl<'hir>, + body: BodyId, + fn_decl_span: Span, + movability: Option<Movability>, + }, /// A block (e.g., `'label: { ... }`). Block(&'hir Block<'hir>, Option<Label>), @@ -3455,7 +3461,7 @@ impl<'hir> Node<'hir> { _ => None, }, Node::Expr(e) => match e.kind { - ExprKind::Closure(..) => Some(FnKind::Closure), + ExprKind::Closure { .. } => Some(FnKind::Closure), _ => None, }, _ => None, diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index bd8587f1106..d1da2519bad 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -1168,14 +1168,13 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) visitor.visit_expr(subexpression); walk_list!(visitor, visit_arm, arms); } - ExprKind::Closure(_, ref function_declaration, body, _fn_decl_span, _gen) => visitor - .visit_fn( - FnKind::Closure, - function_declaration, - body, - expression.span, - expression.hir_id, - ), + ExprKind::Closure { + ref fn_decl, + body, + capture_clause: _, + fn_decl_span: _, + movability: _, + } => visitor.visit_fn(FnKind::Closure, fn_decl, body, expression.span, expression.hir_id), ExprKind::Block(ref block, ref opt_label) => { walk_list!(visitor, visit_label, opt_label); visitor.visit_block(block); |
