]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / run-pass / methods / method-normalize-bounds-issue-20604.rs
1 // Copyright 2015 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.
4 //
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.
10
11 // run-pass
12 #![allow(dead_code)]
13 #![allow(unused_variables)]
14 #![allow(stable_features)]
15
16 // Test that we handle projection types which wind up important for
17 // resolving methods. This test was reduced from a larger example; the
18 // call to `foo()` at the end was failing to resolve because the
19 // winnowing stage of method resolution failed to handle an associated
20 // type projection.
21
22 // pretty-expanded FIXME #23616
23
24 #![feature(associated_types)]
25
26 trait Hasher {
27 type Output;
28 fn finish(&self) -> Self::Output;
29 }
30
31 trait Hash<H: Hasher> {
32 fn hash(&self, h: &mut H);
33 }
34
35 trait HashState {
36 type Wut: Hasher;
37 fn hasher(&self) -> Self::Wut;
38 }
39
40 struct SipHasher;
41 impl Hasher for SipHasher {
42 type Output = u64;
43 fn finish(&self) -> u64 { 4 }
44 }
45
46 impl Hash<SipHasher> for isize {
47 fn hash(&self, h: &mut SipHasher) {}
48 }
49
50 struct SipState;
51 impl HashState for SipState {
52 type Wut = SipHasher;
53 fn hasher(&self) -> SipHasher { SipHasher }
54 }
55
56 struct Map<S> {
57 s: S,
58 }
59
60 impl<S> Map<S>
61 where S: HashState,
62 <S as HashState>::Wut: Hasher<Output=u64>,
63 {
64 fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {}
65 }
66
67 fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
68 map.foo(22);
69 }
70
71 fn main() {}