1 // aux-build:implicit_hasher_macros.rs
5 extern crate implicit_hasher_macros;
8 use std::collections::{HashMap, HashSet};
9 use std::hash::{BuildHasher, Hash};
11 pub trait Foo<T>: Sized {
12 fn make() -> (Self, Self);
15 impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> {
16 fn make() -> (Self, Self) {
17 // OK, don't suggest to modify these
18 let _: HashMap<i32, i32> = HashMap::new();
19 let _: HashSet<i32> = HashSet::new();
21 (HashMap::new(), HashMap::with_capacity(10))
24 impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
25 fn make() -> (Self, Self) {
26 ((HashMap::new(),), (HashMap::with_capacity(10),))
29 impl Foo<i16> for HashMap<String, String> {
30 fn make() -> (Self, Self) {
31 (HashMap::new(), HashMap::with_capacity(10))
35 impl<K: Hash + Eq, V, S: BuildHasher + Default> Foo<i32> for HashMap<K, V, S> {
36 fn make() -> (Self, Self) {
37 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
40 impl<S: BuildHasher + Default> Foo<i64> for HashMap<String, String, S> {
41 fn make() -> (Self, Self) {
42 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
46 impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
47 fn make() -> (Self, Self) {
48 (HashSet::new(), HashSet::with_capacity(10))
51 impl Foo<i16> for HashSet<String> {
52 fn make() -> (Self, Self) {
53 (HashSet::new(), HashSet::with_capacity(10))
57 impl<T: Hash + Eq, S: BuildHasher + Default> Foo<i32> for HashSet<T, S> {
58 fn make() -> (Self, Self) {
59 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
62 impl<S: BuildHasher + Default> Foo<i64> for HashSet<String, S> {
63 fn make() -> (Self, Self) {
64 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
68 pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
72 impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
73 fn make() -> (Self, Self) {
74 (HashMap::new(), HashMap::with_capacity(10))
80 pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
87 // When the macro is in a different file, the suggestion spans can't be combined properly
88 // and should not cause an ICE
91 #[path = "../auxiliary/test_macro.rs"]
93 __implicit_hasher_test_macro!(impl<K, V> for HashMap<K, V> where V: test_macro::A);
96 implicit_hasher_fn!();