// run-rustfix #![allow(unused, clippy::suspicious_map)] use std::collections::{BTreeSet, HashMap, HashSet}; #[warn(clippy::needless_collect)] #[allow(unused_variables, clippy::iter_cloned_collect)] fn main() { let sample = [1; 5]; let indirect_with_into_iter = sample.iter().collect::>(); let indirect_with_iter = sample.iter().collect::>();; let indirect_negative = sample.iter().collect::>();; let len = sample.iter().collect::>().len(); if sample.iter().collect::>().is_empty() { // Empty } sample.iter().cloned().collect::>().contains(&1); sample.iter().map(|x| (x, x)).collect::>().len(); // Notice the `HashSet`--this should not be linted sample.iter().collect::>().len(); // Neither should this sample.iter().collect::>().len(); indirect_with_into_iter.into_iter().map(|x| (x, x+1)).collect::>(); indirect_with_iter.iter().map(|x| (x, x+1)).collect::>(); indirect_negative.iter().map(|x| (x, x+1)).collect::>(); indirect_negative.iter().map(|x| (x, x+1)).collect::>(); }