Skip to content

Commit d0f59f6

Browse files
committed
Fix closures within inline const
1 parent 4060ed7 commit d0f59f6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

compiler/rustc_typeck/src/check/upvar.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,17 @@ impl<'a, 'tcx> Visitor<'tcx> for InferBorrowKindVisitor<'a, 'tcx> {
148148
}
149149

150150
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
151-
if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.kind {
152-
let body = self.fcx.tcx.hir().body(body_id);
153-
self.visit_body(body);
154-
self.fcx.analyze_closure(expr.hir_id, expr.span, body_id, body, cc);
151+
match expr.kind {
152+
hir::ExprKind::Closure(cc, _, body_id, _, _) => {
153+
let body = self.fcx.tcx.hir().body(body_id);
154+
self.visit_body(body);
155+
self.fcx.analyze_closure(expr.hir_id, expr.span, body_id, body, cc);
156+
}
157+
hir::ExprKind::ConstBlock(anon_const) => {
158+
let body = self.fcx.tcx.hir().body(anon_const.body);
159+
self.visit_body(body);
160+
}
161+
_ => {}
155162
}
156163

157164
intravisit::walk_expr(self, expr);

0 commit comments

Comments
 (0)