]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/issue-9394-inherited-calls.rs
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
[rust.git] / tests / ui / traits / issue-9394-inherited-calls.rs
1 // run-pass
2
3 trait Base: Base2 + Base3{
4     fn foo(&self) -> String;
5     fn foo1(&self) -> String;
6     fn foo2(&self) -> String{
7         "base foo2".to_string()
8     }
9 }
10
11 trait Base2: Base3{
12     fn baz(&self) -> String;
13 }
14
15 trait Base3{
16     fn root(&self) -> String;
17 }
18
19 trait Super: Base{
20     fn bar(&self) -> String;
21 }
22
23 struct X;
24
25 impl Base for X {
26     fn foo(&self) -> String{
27         "base foo".to_string()
28     }
29     fn foo1(&self) -> String{
30         "base foo1".to_string()
31     }
32
33 }
34
35 impl Base2 for X {
36     fn baz(&self) -> String{
37         "base2 baz".to_string()
38     }
39 }
40
41 impl Base3 for X {
42     fn root(&self) -> String{
43         "base3 root".to_string()
44     }
45 }
46
47 impl Super for X {
48     fn bar(&self) -> String{
49         "super bar".to_string()
50     }
51 }
52
53 pub fn main() {
54     let n = X;
55     let s = &n as &dyn Super;
56     assert_eq!(s.bar(),"super bar".to_string());
57     assert_eq!(s.foo(),"base foo".to_string());
58     assert_eq!(s.foo1(),"base foo1".to_string());
59     assert_eq!(s.foo2(),"base foo2".to_string());
60     assert_eq!(s.baz(),"base2 baz".to_string());
61     assert_eq!(s.root(),"base3 root".to_string());
62 }