]>
git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-12028.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test an example where we fail to infer the type parameter H. This
12 // is because there is really nothing constraining it. At one time, we
13 // would infer based on the where clauses in scope, but that no longer
17 fn hash2(&self, hasher
: &H
) -> u64;
21 fn input(&mut self, bytes
: &[u8]);
22 fn result(&self) -> u64;
27 fn stream(&self) -> Self::S
;
30 //////////////////////////////////////////////////////////////////////////////
32 trait StreamHash
<H
: StreamHasher
>: Hash
<H
> {
33 fn input_stream(&self, stream
: &mut H
::S
);
36 impl<H
: StreamHasher
> Hash
<H
> for u8 {
37 fn hash2(&self, hasher
: &H
) -> u64 {
38 let mut stream
= hasher
.stream();
39 self.input_stream(&mut stream
); //~ ERROR type annotations required
40 Stream
::result(&stream
)
44 impl<H
: StreamHasher
> StreamHash
<H
> for u8 {
45 fn input_stream(&self, stream
: &mut H
::S
) {
46 Stream
::input(stream
, &[*self]);