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};
14 use std::hash::{BuildHasher, Hash};
16 pub trait Foo<T>: Sized {
17 fn make() -> (Self, Self);
20 impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> {
21 fn make() -> (Self, Self) {
22 // OK, don't suggest to modify these
23 let _: HashMap<i32, i32> = HashMap::new();
24 let _: HashSet<i32> = HashSet::new();
26 (HashMap::new(), HashMap::with_capacity(10))
29 impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
30 fn make() -> (Self, Self) {
31 ((HashMap::new(),), (HashMap::with_capacity(10),))
34 impl Foo<i16> for HashMap<String, String> {
35 fn make() -> (Self, Self) {
36 (HashMap::new(), HashMap::with_capacity(10))
40 impl<K: Hash + Eq, V, S: BuildHasher + Default> Foo<i32> for HashMap<K, V, S> {
41 fn make() -> (Self, Self) {
42 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
45 impl<S: BuildHasher + Default> Foo<i64> for HashMap<String, String, S> {
46 fn make() -> (Self, Self) {
47 (HashMap::default(), HashMap::with_capacity_and_hasher(10, S::default()))
51 impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
52 fn make() -> (Self, Self) {
53 (HashSet::new(), HashSet::with_capacity(10))
56 impl Foo<i16> for HashSet<String> {
57 fn make() -> (Self, Self) {
58 (HashSet::new(), HashSet::with_capacity(10))
62 impl<T: Hash + Eq, S: BuildHasher + Default> Foo<i32> for HashSet<T, S> {
63 fn make() -> (Self, Self) {
64 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
67 impl<S: BuildHasher + Default> Foo<i64> for HashSet<String, S> {
68 fn make() -> (Self, Self) {
69 (HashSet::default(), HashSet::with_capacity_and_hasher(10, S::default()))
73 pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
77 impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
78 fn make() -> (Self, Self) {
79 (HashMap::new(), HashMap::with_capacity(10))
85 pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
92 // When the macro is in a different file, the suggestion spans can't be combined properly
93 // and should not cause an ICE
96 #[path = "../auxiliary/test_macro.rs"]
98 __implicit_hasher_test_macro!(impl<K, V> for HashMap<K, V> where V: test_macro::A);