diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index faf2f7dae08c5..ef905b51edfb2 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -803,7 +803,8 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &hir::Expr) { terminating(r.id); } - hir::ExprIf(_, ref then, Some(ref otherwise)) => { + hir::ExprIf(ref expr, ref then, Some(ref otherwise)) => { + terminating(expr.id); terminating(then.id); terminating(otherwise.id); } diff --git a/src/test/run-pass/issue-12033.rs b/src/test/run-pass/issue-12033.rs new file mode 100644 index 0000000000000..5e1d82ce52cc6 --- /dev/null +++ b/src/test/run-pass/issue-12033.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::RefCell; + +fn main() { + let x = RefCell::new(0); + if *x.borrow() == 0 {} else {} +}