#![warn(clippy::unnecessary_get_then_check)] use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; fn main() { let s: HashSet = HashSet::new(); let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` let s: HashMap = HashMap::new(); let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` let s: BTreeSet = BTreeSet::new(); let _ = s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_some()` let _ = !s.contains("a"); //~ ERROR: unnecessary use of `get("a").is_none()` let s: BTreeMap = BTreeMap::new(); let _ = s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_some()` let _ = !s.contains_key("a"); //~ ERROR: unnecessary use of `get("a").is_none()` // Import to check that the generic annotations are kept! let s: HashSet = HashSet::new(); let _ = s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_some()` let _ = !s.contains::("a"); //~ ERROR: unnecessary use of `get::("a").is_none()` }