1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
13 use std::collections::{HashMap, HashSet};
15 use std::hash::{Hash, BuildHasher};
17 pub trait Foo<T>: Sized {
18 fn make() -> (Self, Self);
21 impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> {
22 fn make() -> (Self, Self) {
23 // OK, don't suggest to modify these
24 let _: HashMap<i32, i32> = HashMap::new();
25 let _: HashSet<i32> = HashSet::new();
27 (HashMap::new(), HashMap::with_capacity(10))
30 impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
31 fn make() -> (Self, Self) {
32 ((HashMap::new(),), (HashMap::with_capacity(10),))
35 impl Foo<i16> for HashMap<String, String> {
36 fn make() -> (Self, Self) {
37 (HashMap::new(), HashMap::with_capacity(10))
41 impl<K: Hash + Eq, V, S: BuildHasher + Default> Foo<i32> for HashMap<K, V, S> {
42 fn make() -> (Self, Self) {
43 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
46 impl<S: BuildHasher + Default> Foo<i64> for HashMap<String, String, S> {
47 fn make() -> (Self, Self) {
48 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
53 impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
54 fn make() -> (Self, Self) {
55 (HashSet::new(), HashSet::with_capacity(10))
58 impl Foo<i16> for HashSet<String> {
59 fn make() -> (Self, Self) {
60 (HashSet::new(), HashSet::with_capacity(10))
64 impl<T: Hash + Eq, S: BuildHasher + Default> Foo<i32> for HashSet<T, S> {
65 fn make() -> (Self, Self) {
66 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
69 impl<S: BuildHasher + Default> Foo<i64> for HashSet<String, S> {
70 fn make() -> (Self, Self) {
71 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
75 pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {
80 impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
81 fn make() -> (Self, Self) {
82 (HashMap::new(), HashMap::with_capacity(10))
88 pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {
96 // When the macro is in a different file, the suggestion spans can't be combined properly
97 // and should not cause an ICE
100 #[path = "../auxiliary/test_macro.rs"] pub mod test_macro;
101 __implicit_hasher_test_macro!(impl<K, V> for HashMap<K, V> where V: test_macro::A);