]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/needless_collect.fixed
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / tools / clippy / tests / ui / needless_collect.fixed
CommitLineData
f20569fa
XL
1// run-rustfix
2
3#![allow(unused, clippy::suspicious_map, clippy::iter_count)]
4
5use std::collections::{BTreeSet, HashMap, HashSet};
6
7#[warn(clippy::needless_collect)]
8#[allow(unused_variables, clippy::iter_cloned_collect, clippy::iter_next_slice)]
9fn main() {
10 let sample = [1; 5];
11 let len = sample.iter().count();
12 if sample.iter().next().is_none() {
13 // Empty
14 }
15 sample.iter().cloned().any(|x| x == 1);
16 sample.iter().map(|x| (x, x)).count();
17 // Notice the `HashSet`--this should not be linted
18 sample.iter().collect::<HashSet<_>>().len();
19 // Neither should this
20 sample.iter().collect::<BTreeSet<_>>().len();
21}