rust/src/test/run-pass/expr-elseif-ref.rs
Brian Anderson a98ea4f3ef rustc: Run block cleanups on else if blocks
With the scheme used to translate 'else if' currently the if expression is
translated in a new (else) scope context. If that if expression wants to
result in a value that requires refcounting then it will need to drop the
refcount in the cleanups of the else block.
2011-05-17 22:25:24 -04:00

18 lines
266 B
Rust

// xfail-stage0
// Make sure we drop the refs of the temporaries needed to return the
// values from the else if branch
fn main() {
let vec[uint] y = [10u];
auto x = if (false) {
y
} else if (true) {
y
} else {
y
};
assert y.(0) == 10u;
}