Make ExprKind::Closure
a struct variant.
This commit is contained in:
parent
fa68e73e99
commit
3039cfeb6a
75 changed files with 251 additions and 216 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue