@@ -22,6 +22,7 @@ mod iter_count;
2222mod iter_next_slice;
2323mod iter_nth;
2424mod iter_nth_zero;
25+ mod iter_skip_next;
2526mod iterator_step_by_zero;
2627mod manual_saturating_arithmetic;
2728mod map_collect_result_unit;
@@ -1730,7 +1731,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
17301731 [ "nth" , "bytes" ] => bytes_nth:: check ( cx, expr, & arg_lists[ 1 ] ) ,
17311732 [ "nth" , ..] => iter_nth_zero:: check ( cx, expr, arg_lists[ 0 ] ) ,
17321733 [ "step_by" , ..] => iterator_step_by_zero:: check ( cx, expr, arg_lists[ 0 ] ) ,
1733- [ "next" , "skip" ] => lint_iter_skip_next ( cx, expr, arg_lists[ 1 ] ) ,
1734+ [ "next" , "skip" ] => iter_skip_next :: check ( cx, expr, arg_lists[ 1 ] ) ,
17341735 [ "collect" , "cloned" ] => iter_cloned_collect:: check ( cx, expr, arg_lists[ 1 ] ) ,
17351736 [ "as_ref" ] => lint_asref ( cx, expr, "as_ref" , arg_lists[ 0 ] ) ,
17361737 [ "as_mut" ] => lint_asref ( cx, expr, "as_mut" , arg_lists[ 0 ] ) ,
@@ -2510,24 +2511,6 @@ fn lint_unnecessary_fold(cx: &LateContext<'_>, expr: &hir::Expr<'_>, fold_args:
25102511 }
25112512}
25122513
2513- fn lint_iter_skip_next ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , skip_args : & [ hir:: Expr < ' _ > ] ) {
2514- // lint if caller of skip is an Iterator
2515- if match_trait_method ( cx, expr, & paths:: ITERATOR ) {
2516- if let [ caller, n] = skip_args {
2517- let hint = format ! ( ".nth({})" , snippet( cx, n. span, ".." ) ) ;
2518- span_lint_and_sugg (
2519- cx,
2520- ITER_SKIP_NEXT ,
2521- expr. span . trim_start ( caller. span ) . unwrap ( ) ,
2522- "called `skip(..).next()` on an iterator" ,
2523- "use `nth` instead" ,
2524- hint,
2525- Applicability :: MachineApplicable ,
2526- ) ;
2527- }
2528- }
2529- }
2530-
25312514fn derefs_to_slice < ' tcx > (
25322515 cx : & LateContext < ' tcx > ,
25332516 expr : & ' tcx hir:: Expr < ' tcx > ,
0 commit comments