2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2012-11-28 20:34:30 +00:00
|
|
|
// B and C both require A, so D does as well, twice, but that's just fine
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
trait A { fn a(&self) -> isize; }
|
|
|
|
trait B: A { fn b(&self) -> isize; }
|
|
|
|
trait C: A { fn c(&self) -> isize; }
|
|
|
|
trait D: B + C { fn d(&self) -> isize; }
|
2012-11-28 20:34:30 +00:00
|
|
|
|
|
|
|
struct S { bogus: () }
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
impl A for S { fn a(&self) -> isize { 10 } }
|
|
|
|
impl B for S { fn b(&self) -> isize { 20 } }
|
|
|
|
impl C for S { fn c(&self) -> isize { 30 } }
|
|
|
|
impl D for S { fn d(&self) -> isize { 40 } }
|
2012-11-28 20:34:30 +00:00
|
|
|
|
2013-02-21 01:07:17 +00:00
|
|
|
fn f<T:D>(x: &T) {
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(x.a(), 10);
|
|
|
|
assert_eq!(x.b(), 20);
|
|
|
|
assert_eq!(x.c(), 30);
|
|
|
|
assert_eq!(x.d(), 40);
|
2012-11-28 20:34:30 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2012-11-28 20:34:30 +00:00
|
|
|
let value = &S { bogus: () };
|
|
|
|
f(value);
|
2013-02-14 19:47:00 +00:00
|
|
|
}
|