2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:7:29
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _: Option<String> = vec.iter().cloned().last();
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.last().cloned()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::iter-overeager-cloned` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::iter_overeager_cloned)]`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:9:29
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _: Option<String> = vec.iter().chain(vec.iter()).cloned().next();
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.next().cloned()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unneeded cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:11:20
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.count()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
= note: `-D clippy::redundant-clone` implied by `-D warnings`
|
2023-08-01 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:13:21
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _: Vec<_> = vec.iter().cloned().take(2).collect();
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^-----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.take(2).cloned()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:15:21
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect();
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^-----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.skip(2).cloned()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:17:13
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
|
2022-06-16 15:39:06 +00:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
|
|
|
| |
|
2023-07-17 08:19:29 +00:00
|
|
|
| help: try: `.nth(2).cloned()`
|
2022-01-17 12:29:07 +00:00
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:19:13
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
|
|
|
|
| _____________^
|
|
|
|
LL | | .iter()
|
|
|
|
LL | | .cloned()
|
|
|
|
LL | | .flatten();
|
|
|
|
| |__________________^
|
|
|
|
|
|
2023-07-17 08:19:29 +00:00
|
|
|
help: try
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
2022-06-16 15:39:06 +00:00
|
|
|
LL ~ .iter()
|
|
|
|
LL ~ .flatten().cloned();
|
2022-01-17 12:29:07 +00:00
|
|
|
|
|
|
|
|
|
2023-08-24 19:32:12 +00:00
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:24:13
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().filter(|x| x.starts_with('2'));
|
|
|
|
| ^^^^^^^^^^----------------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.filter(|&x| x.starts_with('2')).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:26:13
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().find(|x| x == "2");
|
|
|
|
| ^^^^^^^^^^----------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.find(|&x| x == "2").cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:30:17
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().filter(f);
|
|
|
|
| ^^^^^^^^^^-------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.filter(|&x| f(x)).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:31:17
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().find(f);
|
|
|
|
| ^^^^^^^^^^-----------------
|
|
|
|
| |
|
|
|
|
| help: try: `.find(|&x| f(x)).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:37:17
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().filter(f);
|
|
|
|
| ^^^^^^^^^^-------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.filter(|&x| f(x)).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:38:17
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().find(f);
|
|
|
|
| ^^^^^^^^^^-----------------
|
|
|
|
| |
|
|
|
|
| help: try: `.find(|&x| f(x)).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:45:9
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | iter.cloned().filter(move |(&a, b)| a == 1 && b == &target)
|
|
|
|
| ^^^^-------------------------------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.filter(move |&(&a, b)| a == 1 && b == &target).cloned()`
|
|
|
|
|
|
|
|
error: unnecessarily eager cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:56:13
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | iter.cloned().filter(move |S { a, b }| **a == 1 && b == &target)
|
|
|
|
| ^^^^------------------------------------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.filter(move |&S { a, b }| **a == 1 && b == &target).cloned()`
|
|
|
|
|
|
|
|
error: unneeded cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:60:13
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().map(|x| x.len());
|
|
|
|
| ^^^^^^^^^^--------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.map(|x| x.len())`
|
|
|
|
|
|
|
|
error: unneeded cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:65:13
|
2023-08-24 19:32:12 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty()));
|
|
|
|
| ^^^^^^^^^^----------------------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.for_each(|x| assert!(!x.is_empty()))`
|
|
|
|
|
2023-08-20 01:14:52 +00:00
|
|
|
error: unneeded cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:67:13
|
2023-08-20 01:14:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().all(|x| x.len() == 1);
|
|
|
|
| ^^^^^^^^^^-------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.all(|x| x.len() == 1)`
|
|
|
|
|
|
|
|
error: unneeded cloning of iterator items
|
2024-02-17 12:16:29 +00:00
|
|
|
--> tests/ui/iter_overeager_cloned.rs:69:13
|
2023-08-20 01:14:52 +00:00
|
|
|
|
|
|
|
|
LL | let _ = vec.iter().cloned().any(|x| x.len() == 1);
|
|
|
|
| ^^^^^^^^^^-------------------------------
|
|
|
|
| |
|
|
|
|
| help: try: `.any(|x| x.len() == 1)`
|
|
|
|
|
|
|
|
error: aborting due to 19 previous errors
|
2022-01-17 12:29:07 +00:00
|
|
|
|