rust/src/test/compile-fail/loop-does-not-diverge.rs

13 lines
251 B
Rust
Raw Normal View History

2012-03-11 22:17:27 -05:00
// error-pattern:some control paths may return
/* Make sure a loop{} with a break in it can't be
the tailexpr in the body of a diverging function */
fn forever() -> ! {
loop {
break;
}
ret 42;
}
fn main() {
if (1 == 2) { forever(); }
}