diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-06 13:29:21 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2022-11-13 14:04:02 +0000 |
| commit | 290f0781b4507b14060aa04db3f412914b1f117d (patch) | |
| tree | 418da3c3f79306b49b52a335b60cd1de8a3fe999 /compiler/rustc_passes/src | |
| parent | dba1503ed3c364f388128d42633ba00258ffad49 (diff) | |
| download | rust-290f0781b4507b14060aa04db3f412914b1f117d.tar.gz rust-290f0781b4507b14060aa04db3f412914b1f117d.zip | |
Store LocalDefId in hir::Closure.
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/liveness.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/upvars.rs | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index c181de48a9a..0100860afb9 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -413,7 +413,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { } intravisit::walk_expr(self, expr); } - hir::ExprKind::Closure { .. } => { + hir::ExprKind::Closure(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)); @@ -423,8 +423,7 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> { // in better error messages than just pointing at the closure // construction site. let mut call_caps = Vec::new(); - let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id); - if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { + if let Some(upvars) = self.tcx.upvars_mentioned(closure.def_id) { call_caps.extend(upvars.keys().map(|var_id| { let upvar = upvars[var_id]; let upvar_ln = self.add_live_node(UpvarNode(upvar.span)); diff --git a/compiler/rustc_passes/src/upvars.rs b/compiler/rustc_passes/src/upvars.rs index 68d9bf22bf9..9e41efce9ce 100644 --- a/compiler/rustc_passes/src/upvars.rs +++ b/compiler/rustc_passes/src/upvars.rs @@ -75,9 +75,8 @@ impl<'tcx> Visitor<'tcx> for CaptureCollector<'_, 'tcx> { } fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) { - 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) { + if let hir::ExprKind::Closure(closure) = expr.kind { + if let Some(upvars) = self.tcx.upvars_mentioned(closure.def_id) { // Every capture of a closure expression is a local in scope, // that is moved/copied/borrowed into the closure value, and // for this analysis they are like any other access to a local. |
