about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorxFrednet <xFrednet@gmail.com>2021-06-07 23:10:42 +0200
committerxFrednet <xFrednet@gmail.com>2021-06-07 23:20:11 +0200
commitbb3b58cfccdfbc4f95a2f03dc800aa87fd3fdd2c (patch)
treeac85b938bde7635d789e6d9834c98d1140d82eaa /tests
parent967d815a426dd16354dd42c96ad4b3f2eb036f09 (diff)
downloadrust-bb3b58cfccdfbc4f95a2f03dc800aa87fd3fdd2c.tar.gz
rust-bb3b58cfccdfbc4f95a2f03dc800aa87fd3fdd2c.zip
Reuse `is_expr_identity_function` for `flat_map_identity`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/flat_map_identity.fixed5
-rw-r--r--tests/ui/flat_map_identity.rs5
-rw-r--r--tests/ui/flat_map_identity.stderr12
3 files changed, 17 insertions, 5 deletions
diff --git a/tests/ui/flat_map_identity.fixed b/tests/ui/flat_map_identity.fixed
index dfe3bd47e13..1f4b880ef5b 100644
--- a/tests/ui/flat_map_identity.fixed
+++ b/tests/ui/flat_map_identity.fixed
@@ -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();
 }
diff --git a/tests/ui/flat_map_identity.rs b/tests/ui/flat_map_identity.rs
index 393b9569255..de14a06d4e6 100644
--- a/tests/ui/flat_map_identity.rs
+++ b/tests/ui/flat_map_identity.rs
@@ -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);
 }
diff --git a/tests/ui/flat_map_identity.stderr b/tests/ui/flat_map_identity.stderr
index e4686ae5a54..e776c9fdf51 100644
--- a/tests/ui/flat_map_identity.stderr
+++ b/tests/ui/flat_map_identity.stderr
@@ -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