about summary refs log tree commit diff
path: root/clippy_lints/src/methods/utils.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-27 13:44:51 +0000
committerbors <bors@rust-lang.org>2021-04-27 13:44:51 +0000
commit9af07e65aa3f9f7bf753341fc04f42bcbc43c67e (patch)
tree39577f1b2dc0ea55d33f2cf085856f0bccdc7a94 /clippy_lints/src/methods/utils.rs
parent0a330e682410a2b52f31e3f0ee5e6738b7a2227d (diff)
parentd7627dcfc8a60aaedccf002738dc44a2576fa8fd (diff)
downloadrust-9af07e65aa3f9f7bf753341fc04f42bcbc43c67e.tar.gz
rust-9af07e65aa3f9f7bf753341fc04f42bcbc43c67e.zip
Auto merge of #7138 - mgacek8:issue6808_iter_cloned_collect_FN_with_large_array, r=Manishearth
Fix FN in `iter_cloned_collect` with a large array

fixes #6808
changelog: Fix FN in `iter_cloned_collect` with a large array

I spotted that [is_iterable_array](https://github.com/rust-lang/rust-clippy/blob/a362a4d1d0edb66aef186c1d27b28c60573078f4/clippy_lints/src/loops/explicit_iter_loop.rs#L67-L75) function that `explicit_iter_loop` lint is using only works for array sizes <= 32.
There is this comment:
> IntoIterator is currently only implemented for array sizes <= 32 in rustc

I'm a bit confused, because I read that [IntoIterator for arrays](https://doc.rust-lang.org/src/core/array/mod.rs.html#194-201) with const generic `N` is stable since = "1.0.0". Although Const Generics MVP were stabilized in Rust 1.51.

Should I set MSRV for the current change? I will try to test with older compilers soon.
Diffstat (limited to 'clippy_lints/src/methods/utils.rs')
-rw-r--r--clippy_lints/src/methods/utils.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/clippy_lints/src/methods/utils.rs b/clippy_lints/src/methods/utils.rs
index f6bf37e08b9..0daea47816a 100644
--- a/clippy_lints/src/methods/utils.rs
+++ b/clippy_lints/src/methods/utils.rs
@@ -18,9 +18,7 @@ pub(super) fn derefs_to_slice<'tcx>(
             ty::Slice(_) => true,
             ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
             ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::vec_type),
-            ty::Array(_, size) => size
-                .try_eval_usize(cx.tcx, cx.param_env)
-                .map_or(false, |size| size < 32),
+            ty::Array(_, size) => size.try_eval_usize(cx.tcx, cx.param_env).is_some(),
             ty::Ref(_, inner, _) => may_slice(cx, inner),
             _ => false,
         }