mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
505eb53d29
This lint detects loops that unconditionally break or return. Closes #257
41 lines
927 B
Text
41 lines
927 B
Text
error: this loop never actually loops
|
|
--> $DIR/never_loop.rs:8:5
|
|
|
|
|
8 | loop {
|
|
| _____^ starting here...
|
|
9 | | println!("This is only ever printed once");
|
|
10 | | break;
|
|
11 | | }
|
|
| |_____^ ...ending here
|
|
|
|
|
note: lint level defined here
|
|
--> $DIR/never_loop.rs:4:9
|
|
|
|
|
4 | #![deny(never_loop)]
|
|
| ^^^^^^^^^^
|
|
|
|
error: this loop never actually loops
|
|
--> $DIR/never_loop.rs:21:5
|
|
|
|
|
21 | loop {
|
|
| _____^ starting here...
|
|
22 | | loop {
|
|
23 | | // another one
|
|
24 | | break;
|
|
25 | | }
|
|
26 | | break;
|
|
27 | | }
|
|
| |_____^ ...ending here
|
|
|
|
error: this loop never actually loops
|
|
--> $DIR/never_loop.rs:22:9
|
|
|
|
|
22 | loop {
|
|
| _________^ starting here...
|
|
23 | | // another one
|
|
24 | | break;
|
|
25 | | }
|
|
| |_________^ ...ending here
|
|
|
|
error: aborting due to 3 previous errors
|
|
|