]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/map_flatten.stderr
Rollup merge of #98609 - TaKO8Ki:fix-ice-for-associated-constant-generics, r=lcnr
[rust.git] / src / tools / clippy / tests / ui / map_flatten.stderr
1 error: called `map(..).flatten()` on `Option`
2   --> $DIR/map_flatten.rs:8:10
3    |
4 LL |           .map(|x| {
5    |  __________^
6 LL | |             if x <= 5 {
7 LL | |                 Some(x)
8 LL | |             } else {
9 ...  |
10 LL | |         })
11 LL | |         .flatten();
12    | |__________________^
13    |
14    = note: `-D clippy::map-flatten` implied by `-D warnings`
15 help: try replacing `map` with `and_then` and remove the `.flatten()`
16    |
17 LL ~         .and_then(|x| {
18 LL +             if x <= 5 {
19 LL +                 Some(x)
20 LL +             } else {
21 LL +                 None
22 LL +             }
23 LL ~         });
24    |
25
26 error: called `map(..).flatten()` on `Result`
27   --> $DIR/map_flatten.rs:18:10
28    |
29 LL |           .map(|x| {
30    |  __________^
31 LL | |             if x == 1 {
32 LL | |                 Ok(x)
33 LL | |             } else {
34 ...  |
35 LL | |         })
36 LL | |         .flatten();
37    | |__________________^
38    |
39 help: try replacing `map` with `and_then` and remove the `.flatten()`
40    |
41 LL ~         .and_then(|x| {
42 LL +             if x == 1 {
43 LL +                 Ok(x)
44 LL +             } else {
45 LL +                 Err(0)
46 LL +             }
47 LL ~         });
48    |
49
50 error: called `map(..).flatten()` on `Result`
51   --> $DIR/map_flatten.rs:30:10
52    |
53 LL |           .map(|res| {
54    |  __________^
55 LL | |             if res > 0 {
56 LL | |                 do_something();
57 LL | |                 Ok(res)
58 ...  |
59 LL | |         })
60 LL | |         .flatten();
61    | |__________________^
62    |
63 help: try replacing `map` with `and_then` and remove the `.flatten()`
64    |
65 LL ~         .and_then(|res| {
66 LL +             if res > 0 {
67 LL +                 do_something();
68 LL +                 Ok(res)
69 LL +             } else {
70 LL +                 Err(0)
71 LL +             }
72 LL ~         });
73    |
74
75 error: called `map(..).flatten()` on `Iterator`
76   --> $DIR/map_flatten.rs:42:10
77    |
78 LL |           .map(|some_value| {
79    |  __________^
80 LL | |             if some_value > 3 {
81 LL | |                 Some(some_value)
82 LL | |             } else {
83 ...  |
84 LL | |         })
85 LL | |         .flatten()
86    | |__________________^
87    |
88 help: try replacing `map` with `filter_map` and remove the `.flatten()`
89    |
90 LL ~         .filter_map(|some_value| {
91 LL +             if some_value > 3 {
92 LL +                 Some(some_value)
93 LL +             } else {
94 LL +                 None
95 LL +             }
96 LL +         })
97    |
98
99 error: aborting due to 4 previous errors
100