2021-07-17 02:44:19 -05:00
|
|
|
// build-fail
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
|
|
|
#[rustc_dump_vtable]
|
|
|
|
trait A {
|
|
|
|
fn foo_a(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_dump_vtable]
|
|
|
|
trait B: A {
|
|
|
|
fn foo_b(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_dump_vtable]
|
|
|
|
trait C: A {
|
2021-10-03 01:53:02 -05:00
|
|
|
//~^ error vtable
|
2021-07-17 02:44:19 -05:00
|
|
|
fn foo_c(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustc_dump_vtable]
|
|
|
|
trait D: B + C {
|
2021-10-03 01:53:02 -05:00
|
|
|
//~^ error vtable
|
2021-07-17 02:44:19 -05:00
|
|
|
fn foo_d(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
impl A for S {}
|
|
|
|
impl B for S {}
|
|
|
|
impl C for S {}
|
|
|
|
impl D for S {}
|
|
|
|
|
|
|
|
fn foo(d: &dyn D) {
|
|
|
|
d.foo_d();
|
|
|
|
}
|
|
|
|
|
2022-07-17 15:17:25 -05:00
|
|
|
fn bar(d: &dyn C) {
|
|
|
|
d.foo_c();
|
|
|
|
}
|
|
|
|
|
2021-07-17 02:44:19 -05:00
|
|
|
fn main() {
|
|
|
|
foo(&S);
|
2022-07-17 15:17:25 -05:00
|
|
|
bar(&S);
|
2021-07-17 02:44:19 -05:00
|
|
|
}
|