X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_hir_typeck%2Fsrc%2Fexpr_use_visitor.rs;h=275f7d12148c952c7c7b23d17011aa93da921199;hb=a673364c543986789cfbb844c925063519fb872a;hp=fce2a5888ba24fe8fd710764b64ab644d130c58f;hpb=ff118a84cc7cfc3cc5048528de9a54cd752c7559;p=rust.git diff --git a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs index fce2a5888ba..275f7d12148 100644 --- a/compiler/rustc_hir_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_hir_typeck/src/expr_use_visitor.rs @@ -352,8 +352,8 @@ pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) { self.consume_expr(base); } - hir::ExprKind::Closure { .. } => { - self.walk_captures(expr); + hir::ExprKind::Closure(closure) => { + self.walk_captures(closure); } hir::ExprKind::Box(ref base) => { @@ -745,7 +745,7 @@ fn walk_pat( /// /// - When reporting the Place back to the Delegate, ensure that the UpvarId uses the enclosing /// closure as the DefId. - fn walk_captures(&mut self, closure_expr: &hir::Expr<'_>) { + fn walk_captures(&mut self, closure_expr: &hir::Closure<'_>) { fn upvar_is_local_variable<'tcx>( upvars: Option<&'tcx FxIndexMap>, upvar_id: hir::HirId, @@ -757,7 +757,7 @@ fn upvar_is_local_variable<'tcx>( debug!("walk_captures({:?})", closure_expr); let tcx = self.tcx(); - let closure_def_id = tcx.hir().local_def_id(closure_expr.hir_id); + let closure_def_id = closure_expr.def_id; let upvars = tcx.upvars_mentioned(self.body_owner); // For purposes of this function, generator and closures are equivalent. @@ -829,10 +829,11 @@ fn upvar_is_local_variable<'tcx>( // be a local variable PlaceBase::Local(*var_hir_id) }; + let closure_hir_id = tcx.hir().local_def_id_to_hir_id(closure_def_id); let place_with_id = PlaceWithHirId::new( - capture_info.path_expr_id.unwrap_or( - capture_info.capture_kind_expr_id.unwrap_or(closure_expr.hir_id), - ), + capture_info + .path_expr_id + .unwrap_or(capture_info.capture_kind_expr_id.unwrap_or(closure_hir_id)), place.base_ty, place_base, place.projections.clone(),