@@ -22,6 +22,7 @@ mod iter_count;
22
22
mod iter_next_slice;
23
23
mod iter_nth;
24
24
mod iter_nth_zero;
25
+ mod iter_skip_next;
25
26
mod iterator_step_by_zero;
26
27
mod manual_saturating_arithmetic;
27
28
mod map_collect_result_unit;
@@ -1730,7 +1731,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1730
1731
[ "nth" , "bytes" ] => bytes_nth:: check ( cx, expr, & arg_lists[ 1 ] ) ,
1731
1732
[ "nth" , ..] => iter_nth_zero:: check ( cx, expr, arg_lists[ 0 ] ) ,
1732
1733
[ "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 ] ) ,
1734
1735
[ "collect" , "cloned" ] => iter_cloned_collect:: check ( cx, expr, arg_lists[ 1 ] ) ,
1735
1736
[ "as_ref" ] => lint_asref ( cx, expr, "as_ref" , arg_lists[ 0 ] ) ,
1736
1737
[ "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:
2510
2511
}
2511
2512
}
2512
2513
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
-
2531
2514
fn derefs_to_slice < ' tcx > (
2532
2515
cx : & LateContext < ' tcx > ,
2533
2516
expr : & ' tcx hir:: Expr < ' tcx > ,
0 commit comments