@@ -2,79 +2,45 @@ error: called `map(..).flatten()` on `Iterator`
2
2
--> $DIR/map_flatten_fixable.rs:18:47
3
3
|
4
4
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
5
- | ^^^^^^^^^^^^^^^^^^^^^^^^
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)`
6
6
|
7
7
= note: `-D clippy::map-flatten` implied by `-D warnings`
8
- help: try replacing `map` with `filter_map`, and remove the `.flatten()`
9
- |
10
- LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id).collect();
11
- | ~~~~~~~~~~~~~~~~~~~~~
12
8
13
9
error: called `map(..).flatten()` on `Iterator`
14
10
--> $DIR/map_flatten_fixable.rs:19:47
15
11
|
16
12
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
17
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18
- |
19
- help: try replacing `map` with `filter_map`, and remove the `.flatten()`
20
- |
21
- LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_ref).collect();
22
- | ~~~~~~~~~~~~~~~~~~~~~~~~~
13
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)`
23
14
24
15
error: called `map(..).flatten()` on `Iterator`
25
16
--> $DIR/map_flatten_fixable.rs:20:47
26
17
|
27
18
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
28
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
29
- |
30
- help: try replacing `map` with `filter_map`, and remove the `.flatten()`
31
- |
32
- LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(option_id_closure).collect();
33
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)`
34
20
35
21
error: called `map(..).flatten()` on `Iterator`
36
22
--> $DIR/map_flatten_fixable.rs:21:47
37
23
|
38
24
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
39
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40
- |
41
- help: try replacing `map` with `filter_map`, and remove the `.flatten()`
42
- |
43
- LL | let _: Vec<_> = vec![5_i8; 6].into_iter().filter_map(|x| x.checked_add(1)).collect();
44
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))`
45
26
46
27
error: called `map(..).flatten()` on `Iterator`
47
28
--> $DIR/map_flatten_fixable.rs:24:47
48
29
|
49
30
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
50
- | ^^^^^^^^^^^^^^^^^^^^^^^
51
- |
52
- help: try replacing `map` with `flat_map`, and remove the `.flatten()`
53
- |
54
- LL | let _: Vec<_> = vec![5_i8; 6].into_iter().flat_map(|x| 0..x).collect();
55
- | ~~~~~~~~~~~~~~~~~~
31
+ | ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)`
56
32
57
33
error: called `map(..).flatten()` on `Option`
58
34
--> $DIR/map_flatten_fixable.rs:27:40
59
35
|
60
36
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
61
- | ^^^^^^^^^^^^^^^^^^^^
62
- |
63
- help: try replacing `map` with `and_then`, and remove the `.flatten()`
64
- |
65
- LL | let _: Option<_> = (Some(Some(1))).and_then(|x| x);
66
- | ~~~~~~~~~~~~~~~
37
+ | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
67
38
68
39
error: called `map(..).flatten()` on `Result`
69
40
--> $DIR/map_flatten_fixable.rs:30:42
70
41
|
71
42
LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
72
- | ^^^^^^^^^^^^^^^^^^^^
73
- |
74
- help: try replacing `map` with `and_then`, and remove the `.flatten()`
75
- |
76
- LL | let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
77
- | ~~~~~~~~~~~~~~~
43
+ | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
78
44
79
45
error: called `map(..).flatten()` on `Option`
80
46
--> $DIR/map_flatten_fixable.rs:59:10
@@ -89,14 +55,12 @@ LL | | })
89
55
LL | | .flatten();
90
56
| |__________________^
91
57
|
92
- help: try replacing `map` with `and_then`
58
+ help: try replacing `map` with `and_then` and remove the `.flatten()`
93
59
|
94
60
LL ~ .and_then(|_| {
95
61
LL + // we need some newlines
96
62
LL + // so that the span is big enough
97
- |
98
- help: and remove the `.flatten()`
99
- |
63
+ LL + // for a splitted output of the diagnostic
100
64
LL + Some("")
101
65
LL + // whitespace beforehand is important as well
102
66
LL ~ });
0 commit comments