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

12 lines
249 B
Rust
Raw Normal View History

2012-03-11 22:17:27 -05: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-08-01 19:30:05 -05:00
return 42i; //~ ERROR expected `_|_` but found `int`
2012-03-11 22:17:27 -05:00
}
fn main() {
if (1 == 2) { forever(); }
}