]> git.lizzy.rs Git - rust.git/commitdiff
Rename 'flat_map' → 'flat_map_identity'
authorJeremy Stucki <jeremy@myelin.ch>
Sun, 11 Aug 2019 18:34:25 +0000 (20:34 +0200)
committerJeremy Stucki <jeremy@myelin.ch>
Sun, 11 Aug 2019 18:34:25 +0000 (20:34 +0200)
CHANGELOG.md
clippy_lints/src/lib.rs
clippy_lints/src/methods/mod.rs
src/lintlist/mod.rs
tests/ui/unnecessary_flat_map.rs
tests/ui/unnecessary_flat_map.stderr

index 89570267a94a97ebcd20e5cdfdb85d5ca4cd7ac3..87dbe891ff38a29005426a999c815d10899652e1 100644 (file)
@@ -947,7 +947,7 @@ Released 2018-09-13
 [`filter_map_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next
 [`filter_next`]: https://rust-lang.github.io/rust-clippy/master/index.html#filter_next
 [`find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#find_map
-[`flat_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map
+[`flat_map_identity`]: https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_identity
 [`float_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_arithmetic
 [`float_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp
 [`float_cmp_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp_const
index 4c9126045f995538ba9defa4a4b08cb178218c7f..4cc750ceb2f6011cf28f4b69a306c07a8c5021eb 100644 (file)
@@ -643,7 +643,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
         methods::FILTER_MAP,
         methods::FILTER_MAP_NEXT,
         methods::FIND_MAP,
-        methods::FLAT_MAP,
+        methods::FLAT_MAP_IDENTITY,
         methods::MAP_FLATTEN,
         methods::OPTION_MAP_UNWRAP_OR,
         methods::OPTION_MAP_UNWRAP_OR_ELSE,
index 58b33524589a54c21f4bddcbd5997d4e8343a52f..0ab7785501affa3357168e4e900ed70b967a7e7c 100644 (file)
     /// ```rust
     /// iter.flatten()
     /// ```
-    pub FLAT_MAP,
+    pub FLAT_MAP_IDENTITY,
     pedantic,
     "call to `flat_map` where `flatten` is sufficient"
 }
     FILTER_NEXT,
     FILTER_MAP,
     FILTER_MAP_NEXT,
-    FLAT_MAP,
+    FLAT_MAP_IDENTITY,
     FIND_MAP,
     MAP_FLATTEN,
     ITER_NTH,
@@ -953,7 +953,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
             ["map", "find"] => lint_find_map(cx, expr, arg_lists[1], arg_lists[0]),
             ["flat_map", "filter"] => lint_filter_flat_map(cx, expr, arg_lists[1], arg_lists[0]),
             ["flat_map", "filter_map"] => lint_filter_map_flat_map(cx, expr, arg_lists[1], arg_lists[0]),
-            ["flat_map", ..] => lint_flat_map(cx, expr, arg_lists[0]),
+            ["flat_map", ..] => lint_flat_map_identity(cx, expr, arg_lists[0]),
             ["flatten", "map"] => lint_map_flatten(cx, expr, arg_lists[1]),
             ["is_some", "find"] => lint_search_is_some(cx, expr, "find", arg_lists[1], arg_lists[0]),
             ["is_some", "position"] => lint_search_is_some(cx, expr, "position", arg_lists[1], arg_lists[0]),
@@ -2165,7 +2165,11 @@ fn lint_filter_map_flat_map<'a, 'tcx>(
 }
 
 /// lint use of `flat_map` for `Iterators` where `flatten` would be sufficient
-fn lint_flat_map<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, flat_map_args: &'tcx [hir::Expr]) {
+fn lint_flat_map_identity<'a, 'tcx>(
+    cx: &LateContext<'a, 'tcx>,
+    expr: &'tcx hir::Expr,
+    flat_map_args: &'tcx [hir::Expr],
+) {
     if_chain! {
         if match_trait_method(cx, expr, &paths::ITERATOR);
 
@@ -2183,7 +2187,7 @@ fn lint_flat_map<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, fl
         then {
             let msg = "called `flat_map(|x| x)` on an `Iterator`. \
                        This can be simplified by calling `flatten().`";
-            span_lint(cx, FLAT_MAP, expr.span, msg);
+            span_lint(cx, FLAT_MAP_IDENTITY, expr.span, msg);
         }
     }
 
@@ -2201,7 +2205,7 @@ fn lint_flat_map<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr, fl
         then {
             let msg = "called `flat_map(std::convert::identity)` on an `Iterator`. \
                        This can be simplified by calling `flatten().`";
-            span_lint(cx, FLAT_MAP, expr.span, msg);
+            span_lint(cx, FLAT_MAP_IDENTITY, expr.span, msg);
         }
     }
 }
index 08179ec34e8f178a0a3bf3eb725ca18a0ff2f5f8..cfe8dea8837fc13c03df916d3d47ad915c123113 100644 (file)
         module: "methods",
     },
     Lint {
-        name: "flat_map",
+        name: "flat_map_identity",
         group: "pedantic",
         desc: "call to `flat_map` where `flatten` is sufficient",
         deprecation: None,
index b61569d1b93e009901a54af1e32230e6b372f79f..955e791dd2b989972a36dcea2da74e814182d5b5 100644 (file)
@@ -1,4 +1,4 @@
-#![warn(clippy::flat_map)]
+#![warn(clippy::flat_map_identity)]
 
 use std::convert;
 
index c98b403d29c2bc69946479f79aff480dfce240b2..4872e37f32425bf0fab5a261cec86884da19c06d 100644 (file)
@@ -4,7 +4,7 @@ error: called `flat_map(|x| x)` on an `Iterator`. This can be simplified by call
 LL |     iterator.flat_map(|x| x);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: `-D clippy::flat-map` implied by `-D warnings`
+   = note: `-D clippy::flat-map-identity` implied by `-D warnings`
 
 error: called `flat_map(std::convert::identity)` on an `Iterator`. This can be simplified by calling `flatten().`
   --> $DIR/unnecessary_flat_map.rs:10:23