@@ -2,79 +2,45 @@ error: called `map(..).flatten()` on `Iterator`
22 --> $DIR/map_flatten_fixable.rs:18:47
33 |
44LL | 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)`
66 |
77 = 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- | ~~~~~~~~~~~~~~~~~~~~~
128
139error: called `map(..).flatten()` on `Iterator`
1410 --> $DIR/map_flatten_fixable.rs:19:47
1511 |
1612LL | 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)`
2314
2415error: called `map(..).flatten()` on `Iterator`
2516 --> $DIR/map_flatten_fixable.rs:20:47
2617 |
2718LL | 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)`
3420
3521error: called `map(..).flatten()` on `Iterator`
3622 --> $DIR/map_flatten_fixable.rs:21:47
3723 |
3824LL | 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))`
4526
4627error: called `map(..).flatten()` on `Iterator`
4728 --> $DIR/map_flatten_fixable.rs:24:47
4829 |
4930LL | 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)`
5632
5733error: called `map(..).flatten()` on `Option`
5834 --> $DIR/map_flatten_fixable.rs:27:40
5935 |
6036LL | 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)`
6738
6839error: called `map(..).flatten()` on `Result`
6940 --> $DIR/map_flatten_fixable.rs:30:42
7041 |
7142LL | 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)`
7844
7945error: called `map(..).flatten()` on `Option`
8046 --> $DIR/map_flatten_fixable.rs:59:10
@@ -89,14 +55,12 @@ LL | | })
8955LL | | .flatten();
9056 | |__________________^
9157 |
92- help: try replacing `map` with `and_then`
58+ help: try replacing `map` with `and_then` and remove the `.flatten()`
9359 |
9460LL ~ .and_then(|_| {
9561LL + // we need some newlines
9662LL + // so that the span is big enough
97- |
98- help: and remove the `.flatten()`
99- |
63+ LL + // for a splitted output of the diagnostic
10064LL + Some("")
10165LL + // whitespace beforehand is important as well
10266LL ~ });
0 commit comments