Reuse is_expr_identity_function for flat_map_identity
This commit is contained in:
parent
967d815a42
commit
bb3b58cfcc
4 changed files with 28 additions and 38 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, clippy::needless_return)]
|
||||
#![warn(clippy::flat_map_identity)]
|
||||
|
||||
use std::convert;
|
||||
|
|
@ -11,4 +11,7 @@ fn main() {
|
|||
|
||||
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
|
||||
let _ = iterator.flatten();
|
||||
|
||||
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
|
||||
let _ = iterator.flatten();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_imports, clippy::needless_return)]
|
||||
#![warn(clippy::flat_map_identity)]
|
||||
|
||||
use std::convert;
|
||||
|
|
@ -11,4 +11,7 @@ fn main() {
|
|||
|
||||
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
|
||||
let _ = iterator.flat_map(convert::identity);
|
||||
|
||||
let iterator = [[0, 1], [2, 3], [4, 5]].iter();
|
||||
let _ = iterator.flat_map(|x| return x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: called `flat_map(|x| x)` on an `Iterator`
|
||||
error: use of `flat_map` with an identity function
|
||||
--> $DIR/flat_map_identity.rs:10:22
|
||||
|
|
||||
LL | let _ = iterator.flat_map(|x| x);
|
||||
|
|
@ -6,11 +6,17 @@ LL | let _ = iterator.flat_map(|x| x);
|
|||
|
|
||||
= note: `-D clippy::flat-map-identity` implied by `-D warnings`
|
||||
|
||||
error: called `flat_map(std::convert::identity)` on an `Iterator`
|
||||
error: use of `flat_map` with an identity function
|
||||
--> $DIR/flat_map_identity.rs:13:22
|
||||
|
|
||||
LL | let _ = iterator.flat_map(convert::identity);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: use of `flat_map` with an identity function
|
||||
--> $DIR/flat_map_identity.rs:16:22
|
||||
|
|
||||
LL | let _ = iterator.flat_map(|x| return x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `flatten()`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue