rust/tests/ui/iter_overeager_cloned.stderr

71 lines
2.7 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();
| ^^^^^^^^^^----------------
| |
| help: try this: `.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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
| help: try this: `.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();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
| |
| help: try this: `.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();
| ^^^^^^^^^^-----------------
| |
| help: try this: `.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();
| ^^^^^^^^^^-----------------
| |
| help: try this: `.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);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
| |
| help: try this: `.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();
| |__________________^
|
help: try this
|
LL ~ .iter()
LL ~ .flatten().cloned();
2021-12-31 00:39:53 -06:00
|
error: aborting due to 7 previous errors