]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/inheritance/cross-trait-call.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / inheritance / cross-trait-call.rs
1 // run-pass
2 #![allow(dead_code)]
3
4 trait Foo { fn f(&self) -> isize; }
5 trait Bar : Foo { fn g(&self) -> isize; }
6
7 struct A { x: isize }
8
9 impl Foo for A { fn f(&self) -> isize { 10 } }
10
11 impl Bar for A {
12     // Testing that this impl can call the impl of Foo
13     fn g(&self) -> isize { self.f() }
14 }
15
16 pub fn main() {
17     let a = &A { x: 3 };
18     assert_eq!(a.g(), 10);
19 }