@@ -968,34 +968,6 @@ declare_clippy_lint! {
968
968
"using `filter_map` when a more succinct alternative exists"
969
969
}
970
970
971
- declare_clippy_lint ! {
972
- /// **What it does:** Checks for `into_iter` calls on types which should be replaced by `iter` or
973
- /// `iter_mut`.
974
- ///
975
- /// **Why is this bad?** Arrays and `PathBuf` do not yet have an `into_iter` method which move out
976
- /// their content into an iterator. Auto-referencing resolves the `into_iter` call to its reference
977
- /// instead, like `<&[T; N] as IntoIterator>::into_iter`, which just iterates over item references
978
- /// like calling `iter` would. Furthermore, when the standard library actually
979
- /// [implements the `into_iter` method](https://github.com/rust-lang/rust/issues/25725) which moves
980
- /// the content out of the array, the original use of `into_iter` got inferred with the wrong type
981
- /// and the code will be broken.
982
- ///
983
- /// **Known problems:** None
984
- ///
985
- /// **Example:**
986
- ///
987
- /// ```rust
988
- /// let _ = [1, 2, 3].into_iter().map(|x| *x).collect::<Vec<u32>>();
989
- /// ```
990
- /// Could be written as:
991
- /// ```rust
992
- /// let _ = [1, 2, 3].iter().map(|x| *x).collect::<Vec<u32>>();
993
- /// ```
994
- pub INTO_ITER_ON_ARRAY ,
995
- correctness,
996
- "using `.into_iter()` on an array"
997
- }
998
-
999
971
declare_clippy_lint ! {
1000
972
/// **What it does:** Checks for `into_iter` calls on references which should be replaced by `iter`
1001
973
/// or `iter_mut`.
@@ -1133,7 +1105,6 @@ declare_lint_pass!(Methods => [
1133
1105
USELESS_ASREF ,
1134
1106
UNNECESSARY_FOLD ,
1135
1107
UNNECESSARY_FILTER_MAP ,
1136
- INTO_ITER_ON_ARRAY ,
1137
1108
INTO_ITER_ON_REF ,
1138
1109
SUSPICIOUS_MAP ,
1139
1110
UNINIT_ASSUMED_INIT ,
@@ -2786,16 +2757,8 @@ fn lint_asref(cx: &LateContext<'_, '_>, expr: &hir::Expr, call_name: &str, as_re
2786
2757
}
2787
2758
}
2788
2759
2789
- fn ty_has_iter_method (
2790
- cx : & LateContext < ' _ , ' _ > ,
2791
- self_ref_ty : Ty < ' _ > ,
2792
- ) -> Option < ( & ' static Lint , & ' static str , & ' static str ) > {
2760
+ fn ty_has_iter_method ( cx : & LateContext < ' _ , ' _ > , self_ref_ty : Ty < ' _ > ) -> Option < ( & ' static str , & ' static str ) > {
2793
2761
has_iter_method ( cx, self_ref_ty) . map ( |ty_name| {
2794
- let lint = if ty_name == "array" || ty_name == "PathBuf" {
2795
- INTO_ITER_ON_ARRAY
2796
- } else {
2797
- INTO_ITER_ON_REF
2798
- } ;
2799
2762
let mutbl = match self_ref_ty. kind {
2800
2763
ty:: Ref ( _, _, mutbl) => mutbl,
2801
2764
_ => unreachable ! ( ) ,
@@ -2804,18 +2767,18 @@ fn ty_has_iter_method(
2804
2767
hir:: MutImmutable => "iter" ,
2805
2768
hir:: MutMutable => "iter_mut" ,
2806
2769
} ;
2807
- ( lint , ty_name, method_name)
2770
+ ( ty_name, method_name)
2808
2771
} )
2809
2772
}
2810
2773
2811
2774
fn lint_into_iter ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr , self_ref_ty : Ty < ' _ > , method_span : Span ) {
2812
2775
if !match_trait_method ( cx, expr, & paths:: INTO_ITERATOR ) {
2813
2776
return ;
2814
2777
}
2815
- if let Some ( ( lint , kind, method_name) ) = ty_has_iter_method ( cx, self_ref_ty) {
2778
+ if let Some ( ( kind, method_name) ) = ty_has_iter_method ( cx, self_ref_ty) {
2816
2779
span_lint_and_sugg (
2817
2780
cx,
2818
- lint ,
2781
+ INTO_ITER_ON_REF ,
2819
2782
method_span,
2820
2783
& format ! (
2821
2784
"this .into_iter() call is equivalent to .{}() and will not move the {}" ,
0 commit comments