@@ -3,6 +3,7 @@ mod bytes_nth;
3
3
mod clone_on_ref_ptr;
4
4
mod expect_used;
5
5
mod filetype_is_file;
6
+ mod filter_flat_map;
6
7
mod filter_map;
7
8
mod filter_map_identity;
8
9
mod filter_map_map;
@@ -1705,7 +1706,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1705
1706
[ "map" , "filter_map" ] => filter_map_map:: check ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
1706
1707
[ "next" , "filter_map" ] => filter_map_next:: check ( cx, expr, arg_lists[ 1 ] , self . msrv . as_ref ( ) ) ,
1707
1708
[ "map" , "find" ] => filter_map:: check ( cx, expr, true ) ,
1708
- [ "flat_map" , "filter" ] => lint_filter_flat_map ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
1709
+ [ "flat_map" , "filter" ] => filter_flat_map :: check ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
1709
1710
[ "flat_map" , "filter_map" ] => lint_filter_map_flat_map ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
1710
1711
[ "flat_map" , ..] => lint_flat_map_identity ( cx, expr, arg_lists[ 0 ] , method_spans[ 0 ] ) ,
1711
1712
[ "flatten" , "map" ] => lint_map_flatten ( cx, expr, arg_lists[ 1 ] ) ,
@@ -2753,22 +2754,6 @@ fn lint_map_or_none<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
2753
2754
) ;
2754
2755
}
2755
2756
2756
- /// lint use of `filter().flat_map()` for `Iterators`
2757
- fn lint_filter_flat_map < ' tcx > (
2758
- cx : & LateContext < ' tcx > ,
2759
- expr : & ' tcx hir:: Expr < ' _ > ,
2760
- _filter_args : & ' tcx [ hir:: Expr < ' _ > ] ,
2761
- _map_args : & ' tcx [ hir:: Expr < ' _ > ] ,
2762
- ) {
2763
- // lint if caller of `.filter().flat_map()` is an Iterator
2764
- if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2765
- let msg = "called `filter(..).flat_map(..)` on an `Iterator`" ;
2766
- let hint = "this is more succinctly expressed by calling `.flat_map(..)` \
2767
- and filtering by returning `iter::empty()`";
2768
- span_lint_and_help ( cx, FILTER_MAP , expr. span , msg, None , hint) ;
2769
- }
2770
- }
2771
-
2772
2757
/// lint use of `filter_map().flat_map()` for `Iterators`
2773
2758
fn lint_filter_map_flat_map < ' tcx > (
2774
2759
cx : & LateContext < ' tcx > ,
0 commit comments