mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 00:47:16 +00:00
38d4ac7cea
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
115 lines
3.4 KiB
Text
115 lines
3.4 KiB
Text
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:6:5
|
|
|
|
|
LL | / loop {
|
|
LL | | if let Some(_x) = y {
|
|
LL | | let _v = 1;
|
|
LL | | } else {
|
|
LL | | break;
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^ help: try: `while let Some(_x) = y { .. }`
|
|
|
|
|
= note: `-D clippy::while-let-loop` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:20:5
|
|
|
|
|
LL | / loop {
|
|
LL | | match y {
|
|
LL | | Some(_x) => true,
|
|
LL | | None => break,
|
|
LL | | };
|
|
LL | | }
|
|
| |_____^ help: try: `while let Some(_x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:26:5
|
|
|
|
|
LL | / loop {
|
|
LL | | let x = match y {
|
|
LL | | Some(x) => x,
|
|
LL | | None => break,
|
|
... |
|
|
LL | | let _str = "foo";
|
|
LL | | }
|
|
| |_____^ help: try: `while let Some(x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:34:5
|
|
|
|
|
LL | / loop {
|
|
LL | | let x = match y {
|
|
LL | | Some(x) => x,
|
|
LL | | None => break,
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^ help: try: `while let Some(x) = y { .. }`
|
|
|
|
error: this loop could be written as a `while let` loop
|
|
--> $DIR/while_loop.rs:62:5
|
|
|
|
|
LL | / loop {
|
|
LL | | let (e, l) = match "".split_whitespace().next() {
|
|
LL | | Some(word) => (word.is_empty(), word.len()),
|
|
LL | | None => break,
|
|
... |
|
|
LL | | let _ = (e, l);
|
|
LL | | }
|
|
| |_____^ help: try: `while let Some(word) = "".split_whitespace().next() { .. }`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:72:33
|
|
|
|
|
LL | while let Option::Some(x) = iter.next() {
|
|
| ^^^^^^^^^^^ help: try: `for x in iter { .. }`
|
|
|
|
|
= note: `-D clippy::while-let-on-iterator` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:77:25
|
|
|
|
|
LL | while let Some(x) = iter.next() {
|
|
| ^^^^^^^^^^^ help: try: `for x in iter { .. }`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:82:25
|
|
|
|
|
LL | 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:125:5
|
|
|
|
|
LL | / loop {
|
|
LL | | let _ = match iter.next() {
|
|
LL | | Some(ele) => ele,
|
|
LL | | None => break,
|
|
LL | | };
|
|
LL | | loop {}
|
|
LL | | }
|
|
| |_____^ 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:130:9
|
|
|
|
|
LL | loop {}
|
|
| ^^^^^^^
|
|
|
|
|
= note: `-D clippy::empty-loop` implied by `-D warnings`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:188:29
|
|
|
|
|
LL | while let Some(v) = y.next() {
|
|
| ^^^^^^^^ help: try: `for v in y { .. }`
|
|
|
|
error: this loop could be written as a `for` loop
|
|
--> $DIR/while_loop.rs:216:26
|
|
|
|
|
LL | while let Some(..) = values.iter().next() {
|
|
| ^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in values.iter() { .. }`
|
|
|
|
error: aborting due to 12 previous errors
|
|
|