diff options
Diffstat (limited to 'tests/ui/traits/vtable/vtable-diamond.rs')
-rw-r--r-- | tests/ui/traits/vtable/vtable-diamond.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/traits/vtable/vtable-diamond.rs b/tests/ui/traits/vtable/vtable-diamond.rs new file mode 100644 index 000000000..dc3c17ac3 --- /dev/null +++ b/tests/ui/traits/vtable/vtable-diamond.rs @@ -0,0 +1,44 @@ +// 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 { + //~^ error vtable + fn foo_c(&self) {} +} + +#[rustc_dump_vtable] +trait D: B + C { + //~^ error vtable + 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(); +} + +fn bar(d: &dyn C) { + d.foo_c(); +} + +fn main() { + foo(&S); + bar(&S); +} |