Uncomment test for #8734

This commit is contained in:
Alex Macleod 2022-06-30 10:13:54 +00:00
parent 0cb0f76368
commit 6c61f7106f
3 changed files with 59 additions and 31 deletions

View File

@ -34,21 +34,20 @@ fn main() {
} }
fn issue8734() { fn issue8734() {
// let _ = [0u8, 1, 2, 3] let _ = [0u8, 1, 2, 3]
// .into_iter() .into_iter()
// .map(|n| match n { .flat_map(|n| match n {
// 1 => [n 1 => [n
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1)], .saturating_add(1)],
// n => [n], n => [n],
// }) });
// .flatten();
} }
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again #[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again

View File

@ -34,21 +34,21 @@ fn option_id(x: i8) -> Option<i8> {
} }
fn issue8734() { fn issue8734() {
// let _ = [0u8, 1, 2, 3] let _ = [0u8, 1, 2, 3]
// .into_iter() .into_iter()
// .map(|n| match n { .map(|n| match n {
// 1 => [n 1 => [n
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1) .saturating_add(1)
// .saturating_add(1)], .saturating_add(1)],
// n => [n], n => [n],
// }) })
// .flatten(); .flatten();
} }
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again #[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again

View File

@ -42,6 +42,35 @@ error: called `map(..).flatten()` on `Result`
LL | let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten(); 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)` | ^^^^^^^^^^^^^^^^^^^^ help: try replacing `map` with `and_then` and remove the `.flatten()`: `and_then(|x| x)`
error: called `map(..).flatten()` on `Iterator`
--> $DIR/map_flatten_fixable.rs:39:10
|
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` error: called `map(..).flatten()` on `Option`
--> $DIR/map_flatten_fixable.rs:59:10 --> $DIR/map_flatten_fixable.rs:59:10
| |
@ -66,5 +95,5 @@ LL + // whitespace beforehand is important as well
LL ~ }); LL ~ });
| |
error: aborting due to 8 previous errors error: aborting due to 9 previous errors