]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/traits/trait-inheritance-diamond.rs
New upstream version 1.33.0+dfsg1
[rustc.git] / src / test / run-pass / traits / trait-inheritance-diamond.rs
CommitLineData
b7449926 1// run-pass
0bf4aa26 2#![allow(dead_code)]
223e47cc
LB
3// B and C both require A, so D does as well, twice, but that's just fine
4
c34b1796
AL
5
6trait A { fn a(&self) -> isize; }
7trait B: A { fn b(&self) -> isize; }
8trait C: A { fn c(&self) -> isize; }
9trait D: B + C { fn d(&self) -> isize; }
223e47cc
LB
10
11struct S { bogus: () }
12
c34b1796
AL
13impl A for S { fn a(&self) -> isize { 10 } }
14impl B for S { fn b(&self) -> isize { 20 } }
15impl C for S { fn c(&self) -> isize { 30 } }
16impl D for S { fn d(&self) -> isize { 40 } }
223e47cc
LB
17
18fn f<T:D>(x: &T) {
970d7e83
LB
19 assert_eq!(x.a(), 10);
20 assert_eq!(x.b(), 20);
21 assert_eq!(x.c(), 30);
22 assert_eq!(x.d(), 40);
223e47cc
LB
23}
24
25pub fn main() {
26 let value = &S { bogus: () };
27 f(value);
28}