rust/tests/ui/map_flatten_fixable.stderr

100 lines
4.0 KiB
Plaintext
Raw Normal View History

error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:16:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id)`
|
= note: `-D clippy::map-flatten` implied by `-D warnings`
error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:17:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_ref).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_ref)`
error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:18:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(option_id_closure).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(option_id_closure)`
error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:19:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| x.checked_add(1)).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `filter_map` and remove the `.flatten()`: `filter_map(|x| x.checked_add(1))`
error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:22:47
|
LL | let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `flat_map` and remove the `.flatten()`: `flat_map(|x| 0..x)`
error: called `map(..).flatten()` on `Option`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:25:40
|
LL | let _: Option<_> = (Some(Some(1))).map(|x| x).flatten();
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
error: called `map(..).flatten()` on `Result`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:28:42
|
LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
| ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
2022-06-30 05:13:54 -05:00
error: called `map(..).flatten()` on `Iterator`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:37:10
2022-06-30 05:13:54 -05:00
|
LL | .map(|n| match n {
| __________^
LL | | 1 => [n
LL | | .saturating_add(1)
LL | | .saturating_add(1)
... |
LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `flat_map` and remove the `.flatten()`
|
LL ~ .flat_map(|n| match n {
LL + 1 => [n
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)
LL + .saturating_add(1)],
LL + n => [n],
LL ~ });
|
error: called `map(..).flatten()` on `Option`
2023-07-27 06:40:22 -05:00
--> $DIR/map_flatten_fixable.rs:57:10
|
LL | .map(|_| {
| __________^
LL | | // we need some newlines
LL | | // so that the span is big enough
2022-07-13 09:48:32 -05:00
LL | | // for a split output of the diagnostic
... |
LL | | })
LL | | .flatten();
| |__________________^
|
help: try replacing `map` with `and_then` and remove the `.flatten()`
|
LL ~ .and_then(|_| {
LL + // we need some newlines
LL + // so that the span is big enough
2022-07-13 09:48:32 -05:00
LL + // for a split output of the diagnostic
LL + Some("")
LL + // whitespace beforehand is important as well
LL ~ });
|
2022-06-30 05:13:54 -05:00
error: aborting due to 9 previous errors