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

12 lines
245 B
Rust
Raw Normal View History

2012-03-11 20:17:27 -07:00
/* 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;
}
2012-04-06 06:58:41 -07:00
ret 42; //! ERROR expected `_|_` but found `int`
2012-03-11 20:17:27 -07:00
}
fn main() {
if (1 == 2) { forever(); }
}