4 use std::collections::{HashMap, HashSet};
5 use std::hash::{BuildHasher, Hash};
7 pub trait Foo<T>: Sized {
8 fn make() -> (Self, Self);
11 impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> {
12 fn make() -> (Self, Self) {
13 // OK, don't suggest to modify these
14 let _: HashMap<i32, i32> = HashMap::new();
15 let _: HashSet<i32> = HashSet::new();
17 (HashMap::new(), HashMap::with_capacity(10))
20 impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
21 fn make() -> (Self, Self) {
22 ((HashMap::new(),), (HashMap::with_capacity(10),))
25 impl Foo<i16> for HashMap<String, String> {
26 fn make() -> (Self, Self) {
27 (HashMap::new(), HashMap::with_capacity(10))
31 impl<K: Hash + Eq, V, S: BuildHasher + Default> Foo<i32> for HashMap<K, V, S> {
32 fn make() -> (Self, Self) {
33 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
36 impl<S: BuildHasher + Default> Foo<i64> for HashMap<String, String, S> {
37 fn make() -> (Self, Self) {
38 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
42 impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
43 fn make() -> (Self, Self) {
44 (HashSet::new(), HashSet::with_capacity(10))
47 impl Foo<i16> for HashSet<String> {
48 fn make() -> (Self, Self) {
49 (HashSet::new(), HashSet::with_capacity(10))
53 impl<T: Hash + Eq, S: BuildHasher + Default> Foo<i32> for HashSet<T, S> {
54 fn make() -> (Self, Self) {
55 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
58 impl<S: BuildHasher + Default> Foo<i64> for HashSet<String, S> {
59 fn make() -> (Self, Self) {
60 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
64 pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
68 impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
69 fn make() -> (Self, Self) {
70 (HashMap::new(), HashMap::with_capacity(10))
76 pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
83 // When the macro is in a different file, the suggestion spans can't be combined properly
84 // and should not cause an ICE
87 #[path = "../auxiliary/test_macro.rs"]
89 __implicit_hasher_test_macro!(impl<K, V> for HashMap<K, V> where V: test_macro::A);