]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/vtable/vtable-diamond.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / traits / vtable / vtable-diamond.rs
1 // build-fail
2 #![feature(rustc_attrs)]
3
4 #[rustc_dump_vtable]
5 trait A {
6 fn foo_a(&self) {}
7 }
8
9 #[rustc_dump_vtable]
10 trait B: A {
11 fn foo_b(&self) {}
12 }
13
14 #[rustc_dump_vtable]
15 trait C: A {
16 //~^ error vtable
17 fn foo_c(&self) {}
18 }
19
20 #[rustc_dump_vtable]
21 trait D: B + C {
22 //~^ error vtable
23 fn foo_d(&self) {}
24 }
25
26 struct S;
27
28 impl A for S {}
29 impl B for S {}
30 impl C for S {}
31 impl D for S {}
32
33 fn foo(d: &dyn D) {
34 d.foo_d();
35 }
36
37 fn bar(d: &dyn C) {
38 d.foo_c();
39 }
40
41 fn main() {
42 foo(&S);
43 bar(&S);
44 }