]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/trait-upcasting/replace-vptr.rs
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / traits / trait-upcasting / replace-vptr.rs
1 // run-pass
2
3 #![feature(trait_upcasting)]
4 #![allow(incomplete_features)]
5
6 trait A {
7     fn foo_a(&self);
8 }
9
10 trait B {
11     fn foo_b(&self);
12 }
13
14 trait C: A + B {
15     fn foo_c(&self);
16 }
17
18 struct S(i32);
19
20 impl A for S {
21     fn foo_a(&self) {
22         unreachable!();
23     }
24 }
25
26 impl B for S {
27     fn foo_b(&self) {
28         assert_eq!(42, self.0);
29     }
30 }
31
32 impl C for S {
33     fn foo_c(&self) {
34         unreachable!();
35     }
36 }
37
38 fn invoke_inner(b: &dyn B) {
39     b.foo_b();
40 }
41
42 fn invoke_outer(c: &dyn C) {
43     invoke_inner(c);
44 }
45
46 fn main() {
47     let s = S(42);
48     invoke_outer(&s);
49 }