diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-15 19:37:14 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-15 19:37:14 +0900 |
| commit | 87e373e82f1791e42d09c1adc9170879304e62cb (patch) | |
| tree | d563ff456f1b285e0be45b2384e28eb270473317 /compiler/rustc_passes/src | |
| parent | 40912e12f1eb35434fc5489adb6ddcb9b976a7e4 (diff) | |
| parent | 3039cfeb6a24c65ab4b7d25f1c60dc0a5df836ac (diff) | |
| download | rust-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_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/liveness.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/loops.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/naked_functions.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/reachable.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/upvars.rs | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 5c3e7918aa3..8f332ed201d 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -2357,7 +2357,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, }; diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index b09d9831d43..80a263f4cb2 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -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(..) diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_passes/src/loops.rs index 79a6e518011..9cfef26fd03 100644 --- a/compiler/rustc_passes/src/loops.rs +++ b/compiler/rustc_passes/src/loops.rs @@ -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)); diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index c0c696a1175..40844b84af0 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -212,7 +212,7 @@ impl<'tcx> CheckInlineAssembly<'tcx> { | ExprKind::Loop(..) | ExprKind::Match(..) | ExprKind::If(..) - | ExprKind::Closure(..) + | ExprKind::Closure { .. } | ExprKind::Assign(..) | ExprKind::AssignOp(..) | ExprKind::Field(..) diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs index 75376cdc592..6e622ff031e 100644 --- a/compiler/rustc_passes/src/reachable.rs +++ b/compiler/rustc_passes/src/reachable.rs @@ -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 diff --git a/compiler/rustc_passes/src/upvars.rs b/compiler/rustc_passes/src/upvars.rs index 25fe8e45825..97a461272b4 100644 --- a/compiler/rustc_passes/src/upvars.rs +++ b/compiler/rustc_passes/src/upvars.rs @@ -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, |
