1 #![allow(clippy::implicit_hasher)]
3 use std::collections::{HashMap, HashSet};
4 use std::hash::{Hash, Hasher};
5 use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
7 struct Key(AtomicUsize);
10 fn clone(&self) -> Self {
11 Key(AtomicUsize::new(self.0.load(Relaxed)))
15 impl PartialEq for Key {
16 fn eq(&self, other: &Self) -> bool {
17 self.0.load(Relaxed) == other.0.load(Relaxed)
24 fn hash<H: Hasher>(&self, h: &mut H) {
25 self.0.load(Relaxed).hash(h);
29 fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
30 let _other: HashMap<Key, bool> = HashMap::new();
31 m.keys().cloned().collect()
34 fn this_is_ok(_m: &mut HashMap<usize, Key>) {}
40 fn trait_fn(&self, set: std::collections::HashSet<Self::AssociatedType>);
43 fn generics_are_ok_too<K>(_m: &mut HashSet<K>) {
44 // nothing to see here, move along
47 fn tuples<U>(_m: &mut HashMap<((), U), ()>) {}
49 fn tuples_bad<U>(_m: &mut HashMap<(Key, U), bool>) {}
52 let _ = should_not_take_this_arg(&mut HashMap::new(), 1);
53 this_is_ok(&mut HashMap::new());
54 tuples::<Key>(&mut HashMap::new());
55 tuples::<()>(&mut HashMap::new());
56 tuples_bad::<()>(&mut HashMap::new());