rust/tests/ui/iter_overeager_cloned.stderr

71 lines
2.6 KiB
Plaintext
Raw Normal View History

error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:8:29
2021-12-31 00:39:53 -06:00
|
LL | let _: Option<String> = vec.iter().cloned().last();
| ^^^^^^^^^^----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.last().cloned()`
2021-12-31 00:39:53 -06:00
|
= note: `-D clippy::iter-overeager-cloned` implied by `-D warnings`
error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:10:29
2021-12-31 00:39:53 -06:00
|
LL | let _: Option<String> = vec.iter().chain(vec.iter()).cloned().next();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.next().cloned()`
2021-12-31 00:39:53 -06:00
error: unneeded cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:12:20
2021-12-31 00:39:53 -06:00
|
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.count()`
2021-12-31 00:39:53 -06:00
|
= note: `-D clippy::redundant-clone` implied by `-D warnings`
error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:14:21
2021-12-31 00:39:53 -06:00
|
LL | let _: Vec<_> = vec.iter().cloned().take(2).collect();
| ^^^^^^^^^^-----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.take(2).cloned()`
2021-12-31 00:39:53 -06:00
error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:16:21
2021-12-31 00:39:53 -06:00
|
LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect();
| ^^^^^^^^^^-----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.skip(2).cloned()`
2021-12-31 00:39:53 -06:00
error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:18:13
2021-12-31 00:39:53 -06:00
|
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
2023-07-01 06:08:01 -05:00
| help: try: `.nth(2).cloned()`
2021-12-31 00:39:53 -06:00
error: unnecessarily eager cloning of iterator items
2022-03-29 07:51:37 -05:00
--> $DIR/iter_overeager_cloned.rs:20:13
2021-12-31 00:39:53 -06:00
|
LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
| _____________^
LL | | .iter()
LL | | .cloned()
LL | | .flatten();
| |__________________^
|
2023-07-01 06:08:01 -05:00
help: try
2021-12-31 00:39:53 -06:00
|
LL ~ .iter()
LL ~ .flatten().cloned();
2021-12-31 00:39:53 -06:00
|
error: aborting due to 7 previous errors