mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
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:
commit
4198013522
3 changed files with 59 additions and 31 deletions
|
@ -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
|
||||||
|
|
|
@ -34,21 +34,21 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue