//@aux-build:proc_macros.rs #![deny(clippy::implicit_hasher)] #[macro_use] extern crate proc_macros; use std::cmp::Eq; use std::collections::{HashMap, HashSet}; use std::hash::{BuildHasher, Hash}; pub trait Foo: Sized { fn make() -> (Self, Self); } impl Foo for HashMap { fn make() -> (Self, Self) { // OK, don't suggest to modify these let _: HashMap = HashMap::new(); let _: HashSet = HashSet::new(); (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } } impl Foo for (HashMap,) { fn make() -> (Self, Self) { ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),)) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default())) } } impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default())) } } impl Foo for HashSet { fn make() -> (Self, Self) { (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default())) } } pub fn map(map: &mut HashMap) {} pub fn set(set: &mut HashSet) {} #[inline_macros] pub mod gen { use super::*; inline! { impl Foo for HashMap { fn make() -> (Self, Self) { (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default())) } } pub fn bar(_map: &mut HashMap, _set: &mut HashSet) {} } } // When the macro is in a different file, the suggestion spans can't be combined properly // and should not cause an ICE // See #2707 #[macro_use] #[path = "auxiliary/test_macro.rs"] pub mod test_macro; __implicit_hasher_test_macro!(impl for HashMap where V: test_macro::A); // #4260 external! { pub fn f(input: &HashMap) {} } // #7712 pub async fn election_vote(_data: HashMap) {} fn main() {}