]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-12028.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-12028.rs
CommitLineData
1a4d82fc
JJ
1// Test an example where we fail to infer the type parameter H. This
2// is because there is really nothing constraining it. At one time, we
3// would infer based on the where clauses in scope, but that no longer
4// works.
5
6trait Hash<H> {
7 fn hash2(&self, hasher: &H) -> u64;
8}
9
10trait Stream {
11 fn input(&mut self, bytes: &[u8]);
12 fn result(&self) -> u64;
13}
14
15trait StreamHasher {
16 type S : Stream;
17 fn stream(&self) -> Self::S;
18}
19
1a4d82fc
JJ
20trait StreamHash<H: StreamHasher>: Hash<H> {
21 fn input_stream(&self, stream: &mut H::S);
22}
23
24impl<H: StreamHasher> Hash<H> for u8 {
25 fn hash2(&self, hasher: &H) -> u64 {
26 let mut stream = hasher.stream();
e74abb32 27 self.input_stream(&mut stream); //~ ERROR type annotations needed
1a4d82fc
JJ
28 Stream::result(&stream)
29 }
30}
31
32impl<H: StreamHasher> StreamHash<H> for u8 {
33 fn input_stream(&self, stream: &mut H::S) {
85aaf69f 34 Stream::input(stream, &[*self]);
1a4d82fc
JJ
35 }
36}
37
38fn main() {}