Debian Codegraph @

gcc/testsuite/rust/compile/issue-1524.rs

raw
1 // { dg-additional-options "-w -frust-compile-until=nameresolution" }
2 // https://github.com/Rust-GCC/gccrs/issues/1524
3 // https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/src/test/ui/methods/method-normalize-bounds-issue-20604.rs
4 trait Hasher {
5 type Output;
6 fn finish(&self) -> Self::Output;
7 }
8
9 trait Hash<H: Hasher> {
10 fn hash(&self, h: &mut H);
11 }
12
13 trait HashState {
14 type Wut: Hasher;
15 fn hasher(&self) -> Self::Wut;
16 }
17
18 struct SipHasher;
19 impl Hasher for SipHasher {
20 type Output = u64;
21 fn finish(&self) -> u64 { 4 }
22 }
23
24 impl Hash<SipHasher> for isize {
25 fn hash(&self, h: &mut SipHasher) {}
26 }
27
28 struct SipState;
29 impl HashState for SipState {
30 type Wut = SipHasher;
31 fn hasher(&self) -> SipHasher { SipHasher }
32 }
33
34 struct Map<S> {
35 s: S,
36 }
37
38 impl<S> Map<S>
39 where S: HashState,
40 <S as HashState>::Wut: Hasher<Output=u64>,
41 {
42 fn foo<K>(&self, k: K) where K: Hash< <S as HashState>::Wut> {}
43 }
44
45 fn foo<K: Hash<SipHasher>>(map: &Map<SipState>) {
46 map.foo(22);
47 }
48
49 fn main() {}