]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-12028.rs
point at private fields in struct literal
[rust.git] / src / test / ui / issues / issue-12028.rs
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
6 trait Hash<H> {
7     fn hash2(&self, hasher: &H) -> u64;
8 }
9
10 trait Stream {
11     fn input(&mut self, bytes: &[u8]);
12     fn result(&self) -> u64;
13 }
14
15 trait StreamHasher {
16     type S : Stream;
17     fn stream(&self) -> Self::S;
18 }
19
20 trait StreamHash<H: StreamHasher>: Hash<H> {
21     fn input_stream(&self, stream: &mut H::S);
22 }
23
24 impl<H: StreamHasher> Hash<H> for u8 {
25     fn hash2(&self, hasher: &H) -> u64 {
26         let mut stream = hasher.stream();
27         self.input_stream(&mut stream); //~ ERROR type annotations needed
28         Stream::result(&stream)
29     }
30 }
31
32 impl<H: StreamHasher> StreamHash<H> for u8 {
33     fn input_stream(&self, stream: &mut H::S) {
34         Stream::input(stream, &[*self]);
35     }
36 }
37
38 fn main() {}