about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2021-10-24 00:26:40 +0100
committerGary Guo <gary@garyguo.net>2021-11-07 04:00:34 +0000
commitd0f59f6d6575e04d3e4d08e919ce01e29bc9e41e (patch)
tree3e703835f37e35642d0c4d954fb6e46ade5ae3f5
parent4060ed7eff2dfb38ee8f9e3d2806f9d82c2cfc65 (diff)
downloadrust-d0f59f6d6575e04d3e4d08e919ce01e29bc9e41e.tar.gz
rust-d0f59f6d6575e04d3e4d08e919ce01e29bc9e41e.zip
Fix closures within inline const
-rw-r--r--compiler/rustc_typeck/src/check/upvar.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs
index 774d8078e52..5f5d308a332 100644
--- a/compiler/rustc_typeck/src/check/upvar.rs
+++ b/compiler/rustc_typeck/src/check/upvar.rs
@@ -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);