@@ -3,7 +3,6 @@ mod explicit_counter_loop;
3
3
mod explicit_into_iter_loop;
4
4
mod explicit_iter_loop;
5
5
mod for_kv_map;
6
- mod for_loops_over_fallibles;
7
6
mod iter_next_loop;
8
7
mod manual_find;
9
8
mod manual_flatten;
@@ -173,49 +172,6 @@ declare_clippy_lint! {
173
172
"for-looping over `_.next()` which is probably not intended"
174
173
}
175
174
176
- declare_clippy_lint ! {
177
- /// ### What it does
178
- /// Checks for `for` loops over `Option` or `Result` values.
179
- ///
180
- /// ### Why is this bad?
181
- /// Readability. This is more clearly expressed as an `if
182
- /// let`.
183
- ///
184
- /// ### Example
185
- /// ```rust
186
- /// # let opt = Some(1);
187
- /// # let res: Result<i32, std::io::Error> = Ok(1);
188
- /// for x in opt {
189
- /// // ..
190
- /// }
191
- ///
192
- /// for x in &res {
193
- /// // ..
194
- /// }
195
- ///
196
- /// for x in res.iter() {
197
- /// // ..
198
- /// }
199
- /// ```
200
- ///
201
- /// Use instead:
202
- /// ```rust
203
- /// # let opt = Some(1);
204
- /// # let res: Result<i32, std::io::Error> = Ok(1);
205
- /// if let Some(x) = opt {
206
- /// // ..
207
- /// }
208
- ///
209
- /// if let Ok(x) = res {
210
- /// // ..
211
- /// }
212
- /// ```
213
- #[ clippy:: version = "1.45.0" ]
214
- pub FOR_LOOPS_OVER_FALLIBLES ,
215
- suspicious,
216
- "for-looping over an `Option` or a `Result`, which is more clearly expressed as an `if let`"
217
- }
218
-
219
175
declare_clippy_lint ! {
220
176
/// ### What it does
221
177
/// Detects `loop + match` combinations that are easier
@@ -648,7 +604,6 @@ declare_lint_pass!(Loops => [
648
604
EXPLICIT_ITER_LOOP ,
649
605
EXPLICIT_INTO_ITER_LOOP ,
650
606
ITER_NEXT_LOOP ,
651
- FOR_LOOPS_OVER_FALLIBLES ,
652
607
WHILE_LET_LOOP ,
653
608
NEEDLESS_COLLECT ,
654
609
EXPLICIT_COUNTER_LOOP ,
@@ -739,30 +694,22 @@ fn check_for_loop<'tcx>(
739
694
manual_find:: check ( cx, pat, arg, body, span, expr) ;
740
695
}
741
696
742
- fn check_for_loop_arg ( cx : & LateContext < ' _ > , pat : & Pat < ' _ > , arg : & Expr < ' _ > ) {
743
- let mut next_loop_linted = false ; // whether or not ITER_NEXT_LOOP lint was used
744
-
697
+ fn check_for_loop_arg ( cx : & LateContext < ' _ > , _: & Pat < ' _ > , arg : & Expr < ' _ > ) {
745
698
if let ExprKind :: MethodCall ( method, self_arg, [ ] , _) = arg. kind {
746
699
let method_name = method. ident . as_str ( ) ;
747
700
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
748
701
match method_name {
749
702
"iter" | "iter_mut" => {
750
703
explicit_iter_loop:: check ( cx, self_arg, arg, method_name) ;
751
- for_loops_over_fallibles:: check ( cx, pat, self_arg, Some ( method_name) ) ;
752
704
} ,
753
705
"into_iter" => {
754
706
explicit_iter_loop:: check ( cx, self_arg, arg, method_name) ;
755
707
explicit_into_iter_loop:: check ( cx, self_arg, arg) ;
756
- for_loops_over_fallibles:: check ( cx, pat, self_arg, Some ( method_name) ) ;
757
708
} ,
758
709
"next" => {
759
- next_loop_linted = iter_next_loop:: check ( cx, arg) ;
710
+ iter_next_loop:: check ( cx, arg) ;
760
711
} ,
761
712
_ => { } ,
762
713
}
763
714
}
764
-
765
- if !next_loop_linted {
766
- for_loops_over_fallibles:: check ( cx, pat, arg, None ) ;
767
- }
768
715
}
0 commit comments