mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Add test for unnecessary_flat_map
This commit is contained in:
parent
316da7eb41
commit
1fd617d6df
2 changed files with 16 additions and 0 deletions
6
tests/ui/unnecessary_flat_map.rs
Normal file
6
tests/ui/unnecessary_flat_map.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
#![warn(clippy::flat_map)]
|
||||
|
||||
fn main() {
|
||||
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
|
||||
iterator.flat_map(|x| x);
|
||||
}
|
10
tests/ui/unnecessary_flat_map.stderr
Normal file
10
tests/ui/unnecessary_flat_map.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error: called `flat_map(|x| x)` on an `Iterator`. This can be simplified by calling `flatten().`
|
||||
--> $DIR/unnecessary_flat_map.rs:5:5
|
||||
|
|
||||
LL | iterator.flat_map(|x| x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::flat-map` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Add table
Reference in a new issue