mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
114 lines
3.3 KiB
Text
114 lines
3.3 KiB
Text
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:9:5
|
|
|
|
|
9 | / loop {
|
|
10 | | if let Some(_x) = y {
|
|
11 | | let _v = 1;
|
|
12 | | } else {
|
|
13 | | break
|
|
14 | | }
|
|
15 | | }
|
|
| |_____^ help: try: `while let Some(_x) = y { .. }`
|
|
|
|
|
= note: `-D while-let-loop` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:22:5
|
|
|
|
|
22 | / loop {
|
|
23 | | match y {
|
|
24 | | Some(_x) => true,
|
|
25 | | None => break
|
|
26 | | };
|
|
27 | | }
|
|
| |_____^ help: try: `while let Some(_x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:28:5
|
|
|
|
|
28 | / loop {
|
|
29 | | let x = match y {
|
|
30 | | Some(x) => x,
|
|
31 | | None => break
|
|
... |
|
|
34 | | let _str = "foo";
|
|
35 | | }
|
|
| |_____^ help: try: `while let Some(x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:36:5
|
|
|
|
|
36 | / loop {
|
|
37 | | let x = match y {
|
|
38 | | Some(x) => x,
|
|
39 | | None => break,
|
|
... |
|
|
42 | | { let _b = "foobar"; }
|
|
43 | | }
|
|
| |_____^ help: try: `while let Some(x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:58:5
|
|
|
|
|
58 | / loop {
|
|
59 | | let (e, l) = match "".split_whitespace().next() {
|
|
60 | | Some(word) => (word.is_empty(), word.len()),
|
|
61 | | None => break
|
|
... |
|
|
64 | | let _ = (e, l);
|
|
65 | | }
|
|
| |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:68:5
|
|
|
|
|
68 | / while let Option::Some(x) = iter.next() {
|
|
69 | | println!("{}", x);
|
|
70 | | }
|
|
| |_____^ help: try: `for x in iter { .. }`
|
|
|
|
|
= note: `-D while-let-on-iterator` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:73:5
|
|
|
|
|
73 | / while let Some(x) = iter.next() {
|
|
74 | | println!("{}", x);
|
|
75 | | }
|
|
| |_____^ help: try: `for x in iter { .. }`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:78:5
|
|
|
|
|
78 | while let Some(_) = iter.next() {}
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:118:5
|
|
|
|
|
118 | / loop {
|
|
119 | | let _ = match iter.next() {
|
|
120 | | Some(ele) => ele,
|
|
121 | | None => break
|
|
122 | | };
|
|
123 | | loop {}
|
|
124 | | }
|
|
| |_____^ help: try: `while let Some(ele) = iter.next() { .. }`
|
|
|
|
error: empty `loop {}` detected. You may want to either use `panic!()` or add `std::thread::sleep(..);` to the loop body.
|
|
--> $DIR/while_loop.rs:123:9
|
|
|
|
|
123 | loop {}
|
|
| ^^^^^^^
|
|
|
|
|
= note: `-D empty-loop` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:183:9
|
|
|
|
|
183 | / while let Some(v) = y.next() { // use a for loop here
|
|
184 | | }
|
|
| |_________^ help: try: `for v in y { .. }`
|
|
|
|
error: aborting due to 11 previous errors
|
|
|