Make ExprKind::Closure
a struct variant.
This commit is contained in:
parent
fa68e73e99
commit
3039cfeb6a
75 changed files with 251 additions and 216 deletions
|
@ -2340,7 +2340,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
|||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
let target = match expr.kind {
|
||||
hir::ExprKind::Closure(..) => Target::Closure,
|
||||
hir::ExprKind::Closure { .. } => Target::Closure,
|
||||
_ => Target::Expression,
|
||||
};
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
|
|||
}
|
||||
intravisit::walk_expr(self, expr);
|
||||
}
|
||||
hir::ExprKind::Closure(..) => {
|
||||
hir::ExprKind::Closure { .. } => {
|
||||
// Interesting control flow (for loops can contain labeled
|
||||
// breaks or continues)
|
||||
self.add_live_node_for_node(expr.hir_id, ExprNode(expr.span, expr.hir_id));
|
||||
|
@ -833,7 +833,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||
|
||||
hir::ExprKind::Field(ref e, _) => self.propagate_through_expr(&e, succ),
|
||||
|
||||
hir::ExprKind::Closure(..) => {
|
||||
hir::ExprKind::Closure { .. } => {
|
||||
debug!("{:?} is an ExprKind::Closure", expr);
|
||||
|
||||
// the construction of a closure itself is not important,
|
||||
|
@ -1387,7 +1387,7 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||
| hir::ExprKind::AddrOf(..)
|
||||
| hir::ExprKind::Struct(..)
|
||||
| hir::ExprKind::Repeat(..)
|
||||
| hir::ExprKind::Closure(..)
|
||||
| hir::ExprKind::Closure { .. }
|
||||
| hir::ExprKind::Path(_)
|
||||
| hir::ExprKind::Yield(..)
|
||||
| hir::ExprKind::Box(..)
|
||||
|
|
|
@ -57,14 +57,14 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
|
|||
hir::ExprKind::Loop(ref b, _, source, _) => {
|
||||
self.with_context(Loop(source), |v| v.visit_block(&b));
|
||||
}
|
||||
hir::ExprKind::Closure(_, ref function_decl, b, span, movability) => {
|
||||
hir::ExprKind::Closure { ref fn_decl, body, fn_decl_span, movability, .. } => {
|
||||
let cx = if let Some(Movability::Static) = movability {
|
||||
AsyncClosure(span)
|
||||
AsyncClosure(fn_decl_span)
|
||||
} else {
|
||||
Closure(span)
|
||||
Closure(fn_decl_span)
|
||||
};
|
||||
self.visit_fn_decl(&function_decl);
|
||||
self.with_context(cx, |v| v.visit_nested_body(b));
|
||||
self.visit_fn_decl(&fn_decl);
|
||||
self.with_context(cx, |v| v.visit_nested_body(body));
|
||||
}
|
||||
hir::ExprKind::Block(ref b, Some(_label)) => {
|
||||
self.with_context(LabeledBlock, |v| v.visit_block(&b));
|
||||
|
|
|
@ -212,7 +212,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> {
|
|||
| ExprKind::Loop(..)
|
||||
| ExprKind::Match(..)
|
||||
| ExprKind::If(..)
|
||||
| ExprKind::Closure(..)
|
||||
| ExprKind::Closure { .. }
|
||||
| ExprKind::Assign(..)
|
||||
| ExprKind::AssignOp(..)
|
||||
| ExprKind::Field(..)
|
||||
|
|
|
@ -273,7 +273,7 @@ impl<'tcx> ReachableContext<'tcx> {
|
|||
}
|
||||
hir::ImplItemKind::TyAlias(_) => {}
|
||||
},
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(.., body, _, _), .. }) => {
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { body, .. }, .. }) => {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
// Nothing to recurse on for these
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
|
||||
if let hir::ExprKind::Closure(..) = expr.kind {
|
||||
if let hir::ExprKind::Closure { .. } = expr.kind {
|
||||
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
|
||||
if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
|
||||
// Every capture of a closure expression is a local in scope,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue