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.
18 lines
266 B
Rust
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;
|
|
}
|