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