Auto merge of #9071 - Alexendoo:8734, r=dswij

Uncomment test for #8734

I believe the issue was an interaction between rustfix and `span_lint_and_sugg_for_edges`, so this would've been fixed by https://github.com/rust-lang/rust/pull/98261 (Thanks, `@WaffleLapkin!)`

Closes #8734

changelog: none
This commit is contained in:
bors 2022-06-30 10:43:39 +00:00
commit 4198013522
3 changed files with 59 additions and 31 deletions

View file

@ -34,21 +34,20 @@ fn main() {
}
fn issue8734() {
// let _ = [0u8, 1, 2, 3]
// .into_iter()
// .map(|n| match 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)],
// n => [n],
// })
// .flatten();
let _ = [0u8, 1, 2, 3]
.into_iter()
.flat_map(|n| match 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)],
n => [n],
});
}
#[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 main() {
}
fn issue8734() {
// let _ = [0u8, 1, 2, 3]
// .into_iter()
// .map(|n| match 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)],
// n => [n],
// })
// .flatten();
let _ = [0u8, 1, 2, 3]
.into_iter()
.map(|n| match 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)],
n => [n],
})
.flatten();
}
#[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();
| ^^^^^^^^^^^^^^^^^^^^ 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`
--> $DIR/map_flatten_fixable.rs:59:10
|
@ -66,5 +95,5 @@ LL + // whitespace beforehand is important as well
LL ~ });
|
error: aborting due to 8 previous errors
error: aborting due to 9 previous errors