@@ -6,6 +6,7 @@ mod filetype_is_file;
66mod filter_map;
77mod filter_map_identity;
88mod filter_map_map;
9+ mod filter_map_next;
910mod filter_next;
1011mod from_iter_instead_of_collect;
1112mod get_unwrap;
@@ -1702,7 +1703,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
17021703 [ "next" , "iter" ] => iter_next_slice:: check ( cx, expr, arg_lists[ 1 ] ) ,
17031704 [ "map" , "filter" ] => filter_map:: check ( cx, expr, false ) ,
17041705 [ "map" , "filter_map" ] => filter_map_map:: check ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
1705- [ "next" , "filter_map" ] => lint_filter_map_next ( cx, expr, arg_lists[ 1 ] , self . msrv . as_ref ( ) ) ,
1706+ [ "next" , "filter_map" ] => filter_map_next :: check ( cx, expr, arg_lists[ 1 ] , self . msrv . as_ref ( ) ) ,
17061707 [ "map" , "find" ] => filter_map:: check ( cx, expr, true ) ,
17071708 [ "flat_map" , "filter" ] => lint_filter_flat_map ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
17081709 [ "flat_map" , "filter_map" ] => lint_filter_map_flat_map ( cx, expr, arg_lists[ 1 ] , arg_lists[ 0 ] ) ,
@@ -2752,40 +2753,6 @@ fn lint_map_or_none<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, map
27522753 ) ;
27532754}
27542755
2755- const FILTER_MAP_NEXT_MSRV : RustcVersion = RustcVersion :: new ( 1 , 30 , 0 ) ;
2756-
2757- /// lint use of `filter_map().next()` for `Iterators`
2758- fn lint_filter_map_next < ' tcx > (
2759- cx : & LateContext < ' tcx > ,
2760- expr : & ' tcx hir:: Expr < ' _ > ,
2761- filter_args : & ' tcx [ hir:: Expr < ' _ > ] ,
2762- msrv : Option < & RustcVersion > ,
2763- ) {
2764- if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2765- if !meets_msrv ( msrv, & FILTER_MAP_NEXT_MSRV ) {
2766- return ;
2767- }
2768-
2769- let msg = "called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling \
2770- `.find_map(..)` instead";
2771- let filter_snippet = snippet ( cx, filter_args[ 1 ] . span , ".." ) ;
2772- if filter_snippet. lines ( ) . count ( ) <= 1 {
2773- let iter_snippet = snippet ( cx, filter_args[ 0 ] . span , ".." ) ;
2774- span_lint_and_sugg (
2775- cx,
2776- FILTER_MAP_NEXT ,
2777- expr. span ,
2778- msg,
2779- "try this" ,
2780- format ! ( "{}.find_map({})" , iter_snippet, filter_snippet) ,
2781- Applicability :: MachineApplicable ,
2782- ) ;
2783- } else {
2784- span_lint ( cx, FILTER_MAP_NEXT , expr. span , msg) ;
2785- }
2786- }
2787- }
2788-
27892756/// lint use of `filter().flat_map()` for `Iterators`
27902757fn lint_filter_flat_map < ' tcx > (
27912758 cx : & LateContext < ' tcx > ,
0 commit comments