diff --git a/tests/ui/unnecessary_flat_map.rs b/tests/ui/unnecessary_flat_map.rs new file mode 100644 index 00000000000..d0072eca9d2 --- /dev/null +++ b/tests/ui/unnecessary_flat_map.rs @@ -0,0 +1,6 @@ +#![warn(clippy::flat_map)] + +fn main() { + let iterator = [[0, 1], [2, 3], [4, 5]].iter(); + iterator.flat_map(|x| x); +} diff --git a/tests/ui/unnecessary_flat_map.stderr b/tests/ui/unnecessary_flat_map.stderr new file mode 100644 index 00000000000..9ebef07f1b7 --- /dev/null +++ b/tests/ui/unnecessary_flat_map.stderr @@ -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 +