Skip to content

Commit 79783e9

Browse files
committed
Fix implicit_hasher test not compiling
1 parent 3b64ca9 commit 79783e9

File tree

2 files changed

+117
-27
lines changed

2 files changed

+117
-27
lines changed

tests/ui/implicit_hasher.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#[macro_use]
77
extern crate proc_macros;
8-
use proc_macros::external;
98

109
use std::cmp::Eq;
1110
use std::collections::{HashMap, HashSet};
@@ -70,7 +69,7 @@ impl<S: BuildHasher + Default> Foo<i64> for HashSet<String, S> {
7069

7170
pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
7271

73-
#[proc_macros::inline_macros]
72+
#[inline_macros]
7473
pub mod gen {
7574
use super::*;
7675
inline! {

tests/ui/implicit_hasher.stderr

Lines changed: 116 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,131 @@
1-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
2-
--> tests/ui/implicit_hasher.rs:14:1
1+
error: impl for `HashMap` should be generalized over different hashers
2+
--> tests/ui/implicit_hasher.rs:17:35
33
|
4-
LL | pub trait Foo<T>: Sized {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | impl<K: Hash + Eq, V> Foo<i8> for HashMap<K, V> {
5+
| ^^^^^^^^^^^^^
6+
|
7+
note: the lint level is defined here
8+
--> tests/ui/implicit_hasher.rs:3:9
9+
|
10+
LL | #![deny(clippy::implicit_hasher)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^
12+
help: consider adding a type parameter
13+
|
14+
LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashMap<K, V, S> {
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
16+
help: ...and use generic constructor
17+
|
18+
LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default()))
19+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
620

7-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
8-
--> tests/ui/implicit_hasher.rs:71:1
21+
error: impl for `HashMap` should be generalized over different hashers
22+
--> tests/ui/implicit_hasher.rs:26:36
923
|
10-
LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
LL | impl<K: Hash + Eq, V> Foo<i8> for (HashMap<K, V>,) {
25+
| ^^^^^^^^^^^^^
26+
|
27+
help: consider adding a type parameter
28+
|
29+
LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<i8> for (HashMap<K, V, S>,) {
30+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
31+
help: ...and use generic constructor
32+
|
33+
LL | ((HashMap::default(),), (HashMap::with_capacity_and_hasher(10, Default::default()),))
34+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1235

13-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
14-
--> tests/ui/implicit_hasher.rs:74:1
36+
error: impl for `HashMap` should be generalized over different hashers
37+
--> tests/ui/implicit_hasher.rs:31:19
38+
|
39+
LL | impl Foo<i16> for HashMap<String, String> {
40+
| ^^^^^^^^^^^^^^^^^^^^^^^
1541
|
16-
LL | pub mod gen {
17-
| ^^^^^^^^^^^
42+
help: consider adding a type parameter
43+
|
44+
LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashMap<String, String, S> {
45+
| +++++++++++++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~~~~~~~
46+
help: ...and use generic constructor
47+
|
48+
LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default()))
49+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1850

19-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
20-
--> tests/ui/implicit_hasher.rs:92:1
51+
error: impl for `HashSet` should be generalized over different hashers
52+
--> tests/ui/implicit_hasher.rs:48:32
53+
|
54+
LL | impl<T: Hash + Eq> Foo<i8> for HashSet<T> {
55+
| ^^^^^^^^^^
56+
|
57+
help: consider adding a type parameter
2158
|
22-
LL | pub mod test_macro;
23-
| ^^^^^^^^^^^^^^^^^^^
59+
LL | impl<T: Hash + Eq, S: ::std::hash::BuildHasher + Default> Foo<i8> for HashSet<T, S> {
60+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
61+
help: ...and use generic constructor
62+
|
63+
LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default()))
64+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2465

25-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
26-
--> tests/ui/implicit_hasher.rs:96:1
66+
error: impl for `HashSet` should be generalized over different hashers
67+
--> tests/ui/implicit_hasher.rs:53:19
68+
|
69+
LL | impl Foo<i16> for HashSet<String> {
70+
| ^^^^^^^^^^^^^^^
2771
|
28-
LL | external! {
29-
| ^^^^^^^^^
72+
help: consider adding a type parameter
3073
|
31-
= note: this error originates in the macro `external` (in Nightly builds, run with -Z macro-backtrace for more info)
74+
LL | impl<S: ::std::hash::BuildHasher + Default> Foo<i16> for HashSet<String, S> {
75+
| +++++++++++++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~
76+
help: ...and use generic constructor
77+
|
78+
LL | (HashSet::default(), HashSet::with_capacity_and_hasher(10, Default::default()))
79+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3280

33-
error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
34-
--> tests/ui/implicit_hasher.rs:101:1
81+
error: parameter of type `HashMap` should be generalized over different hashers
82+
--> tests/ui/implicit_hasher.rs:70:23
83+
|
84+
LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
85+
| ^^^^^^^^^^^^^^^^^
86+
|
87+
help: consider adding a type parameter
88+
|
89+
LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {}
90+
| +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~
91+
92+
error: parameter of type `HashSet` should be generalized over different hashers
93+
--> tests/ui/implicit_hasher.rs:70:53
94+
|
95+
LL | pub fn foo(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>) {}
96+
| ^^^^^^^^^^^^
97+
|
98+
help: consider adding a type parameter
99+
|
100+
LL | pub fn foo<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {}
101+
| +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~
102+
103+
error: impl for `HashMap` should be generalized over different hashers
104+
--> tests/ui/implicit_hasher.rs:76:43
105+
|
106+
LL | impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
107+
| ^^^^^^^^^^^^^
108+
|
109+
= note: this error originates in the macro `__inline_mac_mod_gen` (in Nightly builds, run with -Z macro-backtrace for more info)
110+
help: consider adding a type parameter
111+
|
112+
LL | impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<u8> for HashMap<K, V, S> {
113+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
114+
help: ...and use generic constructor
115+
|
116+
LL | (HashMap::default(), HashMap::with_capacity_and_hasher(10, Default::default()))
117+
| ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118+
119+
error: parameter of type `HashMap` should be generalized over different hashers
120+
--> tests/ui/implicit_hasher.rs:100:35
35121
|
36122
LL | pub async fn election_vote(_data: HashMap<i32, i32>) {}
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123+
| ^^^^^^^^^^^^^^^^^
124+
|
125+
help: consider adding a type parameter
126+
|
127+
LL | pub async fn election_vote<S: ::std::hash::BuildHasher>(_data: HashMap<i32, i32, S>) {}
128+
| +++++++++++++++++++++++++++++ ~~~~~~~~~~~~~~~~~~~~
38129

39-
error: aborting due to 6 previous errors
130+
error: aborting due to 9 previous errors
40131

0 commit comments

Comments
 (0)