Skip to content

Commit 04297de

Browse files
committed
prepare test for 8734
1 parent 22673bc commit 04297de

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

tests/ui/map_flatten_fixable.fixed

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,28 @@ fn main() {
2929
// mapping to Result on Result
3030
let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
3131

32+
issue8734();
3233
issue8878();
3334
}
3435

36+
fn issue8734() {
37+
// let _ = [0u8, 1, 2, 3]
38+
// .into_iter()
39+
// .map(|n| match n {
40+
// 1 => [n
41+
// .saturating_add(1)
42+
// .saturating_add(1)
43+
// .saturating_add(1)
44+
// .saturating_add(1)
45+
// .saturating_add(1)
46+
// .saturating_add(1)
47+
// .saturating_add(1)
48+
// .saturating_add(1)],
49+
// n => [n],
50+
// })
51+
// .flatten();
52+
}
53+
3554
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again
3655
#[rustfmt::skip] // whitespace is important for this one
3756
fn issue8878() {

tests/ui/map_flatten_fixable.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,28 @@ fn main() {
2929
// mapping to Result on Result
3030
let _: Result<_, &str> = (Ok(Ok(1))).map(|x| x).flatten();
3131

32+
issue8734();
3233
issue8878();
3334
}
3435

36+
fn issue8734() {
37+
// let _ = [0u8, 1, 2, 3]
38+
// .into_iter()
39+
// .map(|n| match n {
40+
// 1 => [n
41+
// .saturating_add(1)
42+
// .saturating_add(1)
43+
// .saturating_add(1)
44+
// .saturating_add(1)
45+
// .saturating_add(1)
46+
// .saturating_add(1)
47+
// .saturating_add(1)
48+
// .saturating_add(1)],
49+
// n => [n],
50+
// })
51+
// .flatten();
52+
}
53+
3554
#[allow(clippy::bind_instead_of_map)] // map + flatten will be suggested to `and_then`, but afterwards `map` is suggested again
3655
#[rustfmt::skip] // whitespace is important for this one
3756
fn issue8878() {

tests/ui/map_flatten_fixable.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ LL | let _: Result<_, &str> = (Ok(Ok(1))).and_then(|x| x);
7777
| ~~~~~~~~~~~~~~~
7878

7979
error: called `map(..).flatten()` on `Option`
80-
--> $DIR/map_flatten_fixable.rs:40:10
80+
--> $DIR/map_flatten_fixable.rs:59:10
8181
|
8282
LL | .map(|_| {
8383
| __________^

0 commit comments

Comments
 (0)