Skip to content

Commit

Permalink
Fix conflicts with double_ended_iterator_last
Browse files Browse the repository at this point in the history
  • Loading branch information
qsantos committed Jan 1, 2025
1 parent 707653f commit 458c955
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/ui/infinite_iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::uninlined_format_args, clippy::double_ended_iterator_last)]

use std::iter::repeat;
fn square_is_lower_64(x: &u32) -> bool {
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/iter_overeager_cloned.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)]
#![allow(dead_code, clippy::let_unit_value, clippy::useless_vec)]
#![allow(
dead_code,
clippy::let_unit_value,
clippy::useless_vec,
clippy::double_ended_iterator_last
)]

fn main() {
let vec = vec!["1".to_string(), "2".to_string(), "3".to_string()];
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/iter_overeager_cloned.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#![warn(clippy::iter_overeager_cloned, clippy::redundant_clone, clippy::filter_next)]
#![allow(dead_code, clippy::let_unit_value, clippy::useless_vec)]
#![allow(
dead_code,
clippy::let_unit_value,
clippy::useless_vec,
clippy::double_ended_iterator_last
)]

fn main() {
let vec = vec!["1".to_string(), "2".to_string(), "3".to_string()];
Expand Down
38 changes: 19 additions & 19 deletions tests/ui/iter_overeager_cloned.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:7:29
--> tests/ui/iter_overeager_cloned.rs:12:29
|
LL | let _: Option<String> = vec.iter().cloned().last();
| ^^^^^^^^^^----------------
Expand All @@ -10,15 +10,15 @@ LL | let _: Option<String> = vec.iter().cloned().last();
= help: to override `-D warnings` add `#[allow(clippy::iter_overeager_cloned)]`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:9:29
--> tests/ui/iter_overeager_cloned.rs:14:29
|
LL | let _: Option<String> = vec.iter().chain(vec.iter()).cloned().next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
| help: try: `.next().cloned()`

error: unneeded cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:11:20
--> tests/ui/iter_overeager_cloned.rs:16:20
|
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
Expand All @@ -29,31 +29,31 @@ LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
= help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:13:21
--> tests/ui/iter_overeager_cloned.rs:18:21
|
LL | let _: Vec<_> = vec.iter().cloned().take(2).collect();
| ^^^^^^^^^^-----------------
| |
| help: try: `.take(2).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:15:21
--> tests/ui/iter_overeager_cloned.rs:20:21
|
LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect();
| ^^^^^^^^^^-----------------
| |
| help: try: `.skip(2).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:17:13
--> tests/ui/iter_overeager_cloned.rs:22:13
|
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
| help: try: `.nth(2).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:19:13
--> tests/ui/iter_overeager_cloned.rs:24:13
|
LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
| _____________^
Expand All @@ -69,95 +69,95 @@ LL ~ .flatten().cloned();
|

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:24:13
--> tests/ui/iter_overeager_cloned.rs:29:13
|
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
--> tests/ui/iter_overeager_cloned.rs:26:13
--> tests/ui/iter_overeager_cloned.rs:31:13
|
LL | let _ = vec.iter().cloned().find(|x| x == "2");
| ^^^^^^^^^^----------------------------
| |
| help: try: `.find(|&x| x == "2").cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:30:17
--> tests/ui/iter_overeager_cloned.rs:35:17
|
LL | let _ = vec.iter().cloned().filter(f);
| ^^^^^^^^^^-------------------
| |
| help: try: `.filter(|&x| f(x)).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:31:17
--> tests/ui/iter_overeager_cloned.rs:36:17
|
LL | let _ = vec.iter().cloned().find(f);
| ^^^^^^^^^^-----------------
| |
| help: try: `.find(|&x| f(x)).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:37:17
--> tests/ui/iter_overeager_cloned.rs:42:17
|
LL | let _ = vec.iter().cloned().filter(f);
| ^^^^^^^^^^-------------------
| |
| help: try: `.filter(|&x| f(x)).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:38:17
--> tests/ui/iter_overeager_cloned.rs:43:17
|
LL | let _ = vec.iter().cloned().find(f);
| ^^^^^^^^^^-----------------
| |
| help: try: `.find(|&x| f(x)).cloned()`

error: unnecessarily eager cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:45:9
--> tests/ui/iter_overeager_cloned.rs:50:9
|
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
--> tests/ui/iter_overeager_cloned.rs:56:13
--> tests/ui/iter_overeager_cloned.rs:61:13
|
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
--> tests/ui/iter_overeager_cloned.rs:60:13
--> tests/ui/iter_overeager_cloned.rs:65:13
|
LL | let _ = vec.iter().cloned().map(|x| x.len());
| ^^^^^^^^^^--------------------------
| |
| help: try: `.map(|x| x.len())`

error: unneeded cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:65:13
--> tests/ui/iter_overeager_cloned.rs:70:13
|
LL | let _ = vec.iter().cloned().for_each(|x| assert!(!x.is_empty()));
| ^^^^^^^^^^----------------------------------------------
| |
| help: try: `.for_each(|x| assert!(!x.is_empty()))`

error: unneeded cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:67:13
--> tests/ui/iter_overeager_cloned.rs:72:13
|
LL | let _ = vec.iter().cloned().all(|x| x.len() == 1);
| ^^^^^^^^^^-------------------------------
| |
| help: try: `.all(|x| x.len() == 1)`

error: unneeded cloning of iterator items
--> tests/ui/iter_overeager_cloned.rs:69:13
--> tests/ui/iter_overeager_cloned.rs:74:13
|
LL | let _ = vec.iter().cloned().any(|x| x.len() == 1);
| ^^^^^^^^^^-------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/starts_ends_with.fixed
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if, dead_code, unused_must_use)]
#![allow(clippy::needless_if, dead_code, unused_must_use, clippy::double_ended_iterator_last)]

fn main() {}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/starts_ends_with.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::needless_if, dead_code, unused_must_use)]
#![allow(clippy::needless_if, dead_code, unused_must_use, clippy::double_ended_iterator_last)]

fn main() {}

Expand Down

0 comments on commit 458c955

Please sign in to comment.