rust/src/test/run-pass/unreachable-code.rs

58 lines
922 B
Rust
Raw Normal View History

2011-09-23 04:33:11 -05:00
// xfail-pretty
fn id(x: bool) -> bool { x }
fn call_id() {
let c <- fail;
id(c);
}
fn call_id_2() { id(true) && id(ret); }
fn call_id_4() { while id(ret) { } }
2011-09-25 23:01:50 -05:00
fn bind_id_1() { bind id(fail); }
fn bind_id_2() { bind id(ret); }
2011-09-25 22:57:44 -05:00
fn fail_fail() { fail fail; }
fn log_fail() { log(error, fail); }
fn log_ret() { log(error, ret); }
fn log_break() { loop { log(error, break); } }
fn log_cont() { do { log(error, cont); } while false }
fn ret_ret() -> int { ret 3 + (ret 2); }
fn ret_guard() {
alt check 2 {
x if (ret) { x; }
}
}
fn rec_ret() { let _r: {c: int} = {c: ret}; }
2011-09-27 13:05:16 -05:00
fn vec_ret() { let _v: [int] = [1, 2, ret, 4]; }
2011-09-27 13:05:16 -05:00
fn fail_then_concat() {
let mut x = [], y = [3];
fail;
x += y;
"good" + "bye";
}
2011-09-27 13:05:16 -05:00
fn main() {
// Call the functions that don't fail.
rec_ret();
vec_ret();
ret_ret();
log_ret();
call_id_2();
call_id_4();
bind_id_2();
ret_guard();
}