]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_passes/src/region.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / compiler / rustc_passes / src / region.rs
index c133f1a041719b73d0fbb8d29f5d31d967132ef5..08702cad41c8b92b5e0a80676f16dd22d6e5b6c0 100644 (file)
@@ -233,14 +233,12 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
                 terminating(r.hir_id.local_id);
             }
 
-            hir::ExprKind::If(ref expr, ref then, Some(ref otherwise)) => {
-                terminating(expr.hir_id.local_id);
+            hir::ExprKind::If(_, ref then, Some(ref otherwise)) => {
                 terminating(then.hir_id.local_id);
                 terminating(otherwise.hir_id.local_id);
             }
 
-            hir::ExprKind::If(ref expr, ref then, None) => {
-                terminating(expr.hir_id.local_id);
+            hir::ExprKind::If(_, ref then, None) => {
                 terminating(then.hir_id.local_id);
             }
 
@@ -392,6 +390,25 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
             }
         }
 
+        hir::ExprKind::If(ref cond, ref then, Some(ref otherwise)) => {
+            let expr_cx = visitor.cx;
+            visitor.enter_scope(Scope { id: then.hir_id.local_id, data: ScopeData::IfThen });
+            visitor.cx.var_parent = visitor.cx.parent;
+            visitor.visit_expr(cond);
+            visitor.visit_expr(then);
+            visitor.cx = expr_cx;
+            visitor.visit_expr(otherwise);
+        }
+
+        hir::ExprKind::If(ref cond, ref then, None) => {
+            let expr_cx = visitor.cx;
+            visitor.enter_scope(Scope { id: then.hir_id.local_id, data: ScopeData::IfThen });
+            visitor.cx.var_parent = visitor.cx.parent;
+            visitor.visit_expr(cond);
+            visitor.visit_expr(then);
+            visitor.cx = expr_cx;
+        }
+
         _ => intravisit::walk_expr(visitor, expr),
     }