1 use std::collections::{HashMap, HashSet};
2 use std::hash::{Hash, Hasher};
3 use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
5 struct Key(AtomicUsize);
8 fn clone(&self) -> Self {
9 Key(AtomicUsize::new(self.0.load(Relaxed)))
13 impl PartialEq for Key {
14 fn eq(&self, other: &Self) -> bool {
15 self.0.load(Relaxed) == other.0.load(Relaxed)
22 fn hash<H: Hasher>(&self, h: &mut H) {
23 self.0.load(Relaxed).hash(h);
27 fn should_not_take_this_arg(m: &mut HashMap<Key, usize>, _n: usize) -> HashSet<Key> {
28 let _other: HashMap<Key, bool> = HashMap::new();
29 m.keys().cloned().collect()
32 fn this_is_ok(_m: &mut HashMap<usize, Key>) {}
38 fn trait_fn(&self, set: std::collections::HashSet<Self::AssociatedType>);
41 fn generics_are_ok_too<K>(_m: &mut HashSet<K>) {
42 // nothing to see here, move along
45 fn tuples<U>(_m: &mut HashMap<((), U), ()>) {}
47 fn tuples_bad<U>(_m: &mut HashMap<(Key, U), bool>) {}
50 let _ = should_not_take_this_arg(&mut HashMap::new(), 1);
51 this_is_ok(&mut HashMap::new());
52 tuples::<Key>(&mut HashMap::new());
53 tuples::<()>(&mut HashMap::new());
54 tuples_bad::<()>(&mut HashMap::new());