Skip to content

Commit 473f7cd

Browse files
committed
add a test with comments
1 parent 2be04b4 commit 473f7cd

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

tests/ui/filter_map_next.fixed

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ fn main() {
1919
None
2020
}
2121
});
22+
23+
let element: Option<i32> = a
24+
// very important comment -- don't delete!
25+
.iter().find_map(|s| {
26+
// another extremely important comment
27+
s.parse().ok()
28+
});
29+
//~^^^^^^^^ filter_map_next
2230
}
2331

2432
#[clippy::msrv = "1.29"]

tests/ui/filter_map_next.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ fn main() {
2121
}
2222
})
2323
.next();
24+
25+
let element: Option<i32> = a
26+
// very important comment -- don't delete!
27+
.iter()
28+
.filter_map(|s| {
29+
// another extremely important comment
30+
s.parse().ok()
31+
})
32+
.next();
33+
//~^^^^^^^^ filter_map_next
2434
}
2535

2636
#[clippy::msrv = "1.29"]

tests/ui/filter_map_next.stderr

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,30 @@ LL ~ });
3838
|
3939

4040
error: called `filter_map(..).next()` on an `Iterator`
41-
--> tests/ui/filter_map_next.rs:35:26
41+
--> tests/ui/filter_map_next.rs:25:32
42+
|
43+
LL | let element: Option<i32> = a
44+
| ________________________________^
45+
LL | | // very important comment -- don't delete!
46+
LL | | .iter()
47+
LL | | .filter_map(|s| {
48+
... |
49+
LL | | })
50+
LL | | .next();
51+
| |_______________^
52+
|
53+
help: use `.find_map(..)` instead
54+
|
55+
LL ~ let element: Option<i32> = a
56+
LL + // very important comment -- don't delete!
57+
LL + .iter().find_map(|s| {
58+
LL + // another extremely important comment
59+
LL + s.parse().ok()
60+
LL ~ });
61+
|
62+
63+
error: called `filter_map(..).next()` on an `Iterator`
64+
--> tests/ui/filter_map_next.rs:45:26
4265
|
4366
LL | let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
4467
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -49,5 +72,5 @@ LL - let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
4972
LL + let _: Option<i32> = a.iter().find_map(|s| s.parse().ok());
5073
|
5174

52-
error: aborting due to 3 previous errors
75+
error: aborting due to 4 previous errors
5376

0 commit comments

Comments
 (0)