Skip to content

Commit

Permalink
Fix closures within inline const
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Nov 7, 2021
1 parent 4060ed7 commit d0f59f6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,17 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> {
}

fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind {
let body = self.fcx.tcx.hir().body(body_id);
self.visit_body(body);
self.fcx.analyze_closure(expr.hir_id, expr.span, body_id, body, cc);
match expr.kind {
hir::ExprKind::Closure(cc, _, body_id, _, _) => {
let body = self.fcx.tcx.hir().body(body_id);
self.visit_body(body);
self.fcx.analyze_closure(expr.hir_id, expr.span, body_id, body, cc);
}
hir::ExprKind::ConstBlock(anon_const) => {
let body = self.fcx.tcx.hir().body(anon_const.body);
self.visit_body(body);
}
_ => {}
}

intravisit::walk_expr(self, expr);
Expand Down

0 comments on commit d0f59f6

Please sign in to comment.