]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_passes/src/upvars.rs
Rollup merge of #104747 - petrochenkov:ctorfields, r=cjgillot
[rust.git] / compiler / rustc_passes / src / upvars.rs
index 68d9bf22bf9c046f29fc567f37a1eda4ef44ff5a..9e41efce9ceaf6ae56b65c6176fdd28d1deb4fe8 100644 (file)
@@ -75,9 +75,8 @@ fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) {
     }
 
     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.