]> git.lizzy.rs Git - rust.git/blob - tests/ui/for_loop_over_option_result.stderr
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / for_loop_over_option_result.stderr
1 error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement.
2   --> $DIR/for_loop_over_option_result.rs:11:14
3    |
4 LL |     for x in option {
5    |              ^^^^^^
6    |
7    = note: `-D clippy::for-loop-over-option` implied by `-D warnings`
8    = help: consider replacing `for x in option` with `if let Some(x) = option`
9
10 error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement.
11   --> $DIR/for_loop_over_option_result.rs:16:14
12    |
13 LL |     for x in result {
14    |              ^^^^^^
15    |
16    = note: `-D clippy::for-loop-over-result` implied by `-D warnings`
17    = help: consider replacing `for x in result` with `if let Ok(x) = result`
18
19 error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
20   --> $DIR/for_loop_over_option_result.rs:20:14
21    |
22 LL |     for x in option.ok_or("x not found") {
23    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
24    |
25    = help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
26
27 error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
28   --> $DIR/for_loop_over_option_result.rs:26:14
29    |
30 LL |     for x in v.iter().next() {
31    |              ^^^^^^^^^^^^^^^
32    |
33    = note: `#[deny(clippy::iter_next_loop)]` on by default
34
35 error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement.
36   --> $DIR/for_loop_over_option_result.rs:31:14
37    |
38 LL |     for x in v.iter().next().and(Some(0)) {
39    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40    |
41    = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
42
43 error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
44   --> $DIR/for_loop_over_option_result.rs:35:14
45    |
46 LL |     for x in v.iter().next().ok_or("x not found") {
47    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48    |
49    = help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
50
51 error: this loop never actually loops
52   --> $DIR/for_loop_over_option_result.rs:47:5
53    |
54 LL | /     while let Some(x) = option {
55 LL | |         println!("{}", x);
56 LL | |         break;
57 LL | |     }
58    | |_____^
59    |
60    = note: `#[deny(clippy::never_loop)]` on by default
61
62 error: this loop never actually loops
63   --> $DIR/for_loop_over_option_result.rs:53:5
64    |
65 LL | /     while let Ok(x) = result {
66 LL | |         println!("{}", x);
67 LL | |         break;
68 LL | |     }
69    | |_____^
70
71 error: aborting due to 8 previous errors
72