Skip to content

Commit 1fd617d

Browse files
committed
Add test for unnecessary_flat_map
1 parent 316da7e commit 1fd617d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

tests/ui/unnecessary_flat_map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![warn(clippy::flat_map)]
2+
3+
fn main() {
4+
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
5+
iterator.flat_map(|x| x);
6+
}

tests/ui/unnecessary_flat_map.stderr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: called `flat_map(|x| x)` on an `Iterator`. This can be simplified by calling `flatten().`
2+
--> $DIR/unnecessary_flat_map.rs:5:5
3+
|
4+
LL | iterator.flat_map(|x| x);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::flat-map` implied by `-D warnings`
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)