]> git.lizzy.rs Git - rust.git/blob - tests/ui/methods/method-normalize-bounds-issue-20604.rs
Rollup merge of #107125 - WaffleLapkin:expect_an_item_in_your_hir_by_the_next_morning...
[rust.git] / tests / ui / methods / method-normalize-bounds-issue-20604.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_variables)]
4 #![allow(stable_features)]
5
6 // Test that we handle projection types which wind up important for
7 // resolving methods. This test was reduced from a larger example; the
8 // call to `foo()` at the end was failing to resolve because the
9 // winnowing stage of method resolution failed to handle an associated
10 // type projection.
11
12 // pretty-expanded FIXME #23616
13
14 #![feature(associated_types)]
15
16 trait Hasher {
17     type Output;
18     fn finish(&self) -> Self::Output;
19 }
20
21 trait Hash<H: Hasher> {
22     fn hash(&self, h: &mut H);
23 }
24
25 trait HashState {
26     type Wut: Hasher;
27     fn hasher(&self) -> Self::Wut;
28 }
29
30 struct SipHasher;
31 impl Hasher for SipHasher {
32     type Output = u64;
33     fn finish(&self) -> u64 { 4 }
34 }
35
36 impl Hash<SipHasher> for isize {
37     fn hash(&self, h: &mut SipHasher) {}
38 }
39
40 struct SipState;
41 impl HashState for SipState {
42     type Wut = SipHasher;
43     fn hasher(&self) -> SipHasher { SipHasher }
44 }
45
46 struct Map<S> {
47     s: S,
48 }
49
50 impl<S> Map<S>
51     where S: HashState,
52           <S as HashState>::Wut: Hasher<Output=u64>,
53 {
54     fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {}
55 }
56
57 fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
58     map.foo(22);
59 }
60
61 fn main() {}