Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystucki committed Aug 13, 2019
1 parent d578c43 commit 2fe5e2c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions tests/ui/unnecessary_flat_map.fixed
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// run-rustfix

#![allow(unused_imports)]
#![warn(clippy::flat_map_identity)]

use std::convert;

fn main() {
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
iterator.flatten();
let _ = iterator.flatten();

let iterator = [[0, 1], [2, 3], [4, 5]].iter();
iterator.flatten();
let _ = iterator.flatten();
}
5 changes: 3 additions & 2 deletions tests/ui/unnecessary_flat_map.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// run-rustfix

#![allow(unused_imports)]
#![warn(clippy::flat_map_identity)]

use std::convert;

fn main() {
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
iterator.flat_map(|x| x);
let _ = iterator.flat_map(|x| x);

let iterator = [[0, 1], [2, 3], [4, 5]].iter();
iterator.flat_map(convert::identity);
let _ = iterator.flat_map(convert::identity);
}
12 changes: 6 additions & 6 deletions tests/ui/unnecessary_flat_map.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: called `flat_map(|x| x)` on an `Iterator`
--> $DIR/unnecessary_flat_map.rs:9:14
--> $DIR/unnecessary_flat_map.rs:10:22
|
LL | iterator.flat_map(|x| x);
| ^^^^^^^^^^^^^^^ help: try: `flatten()`
LL | let _ = iterator.flat_map(|x| x);
| ^^^^^^^^^^^^^^^ help: try: `flatten()`
|
= note: `-D clippy::flat-map-identity` implied by `-D warnings`

error: called `flat_map(std::convert::identity)` on an `Iterator`
--> $DIR/unnecessary_flat_map.rs:12:14
--> $DIR/unnecessary_flat_map.rs:13:22
|
LL | iterator.flat_map(convert::identity);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()`
LL | let _ = iterator.flat_map(convert::identity);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()`

error: aborting due to 2 previous errors

0 comments on commit 2fe5e2c

Please sign in to comment.