rust/tests/ui/never_loop.rs
Andre Bogus 505eb53d29 New never loop lint
This lint detects loops that unconditionally break or return.

Closes #257
2017-02-17 04:53:14 +01:00

35 lines
500 B
Rust

#![feature(plugin)]
#![plugin(clippy)]
#![deny(never_loop)]
#![allow(dead_code, unused)]
fn main() {
loop {
println!("This is only ever printed once");
break;
}
let x = 1;
loop {
println!("This, too"); // but that's OK
if x == 1 {
break;
}
}
loop {
loop {
// another one
break;
}
break;
}
loop {
loop {
if x == 1 { return; }
}
}
}