]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/inheritance/auto.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / inheritance / auto.rs
1 // run-pass
2 #![allow(dead_code)]
3 // Testing that this impl turns A into a Quux, because
4 // A is already a Foo Bar Baz
5
6 impl<T:Foo + Bar + Baz> Quux for T { }
7
8 trait Foo { fn f(&self) -> isize; }
9 trait Bar { fn g(&self) -> isize; }
10 trait Baz { fn h(&self) -> isize; }
11
12 trait Quux: Foo + Bar + Baz { }
13
14 struct A { x: isize }
15
16 impl Foo for A { fn f(&self) -> isize { 10 } }
17 impl Bar for A { fn g(&self) -> isize { 20 } }
18 impl Baz for A { fn h(&self) -> isize { 30 } }
19
20 fn f<T:Quux>(a: &T) {
21     assert_eq!(a.f(), 10);
22     assert_eq!(a.g(), 20);
23     assert_eq!(a.h(), 30);
24 }
25
26 pub fn main() {
27     let a = &A { x: 3 };
28     f(a);
29 }