]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/trait-upcasting/subtrait-method.rs
Rollup merge of #106766 - GuillaumeGomez:rm-stripper-dead-code, r=notriddle
[rust.git] / tests / ui / traits / trait-upcasting / subtrait-method.rs
1 #![feature(trait_upcasting)]
2
3 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
4     fn a(&self) -> i32 {
5         10
6     }
7
8     fn z(&self) -> i32 {
9         11
10     }
11
12     fn y(&self) -> i32 {
13         12
14     }
15 }
16
17 trait Bar: Foo {
18     fn b(&self) -> i32 {
19         20
20     }
21
22     fn w(&self) -> i32 {
23         21
24     }
25 }
26
27 trait Baz: Bar {
28     fn c(&self) -> i32 {
29         30
30     }
31 }
32
33 impl Foo for i32 {
34     fn a(&self) -> i32 {
35         100
36     }
37 }
38
39 impl Bar for i32 {
40     fn b(&self) -> i32 {
41         200
42     }
43 }
44
45 impl Baz for i32 {
46     fn c(&self) -> i32 {
47         300
48     }
49 }
50
51 fn main() {
52     let baz: &dyn Baz = &1;
53
54     let bar: &dyn Bar = baz;
55     bar.c();
56     //~^ ERROR no method named `c` found for reference `&dyn Bar` in the current scope [E0599]
57
58     let foo: &dyn Foo = baz;
59     foo.b();
60     //~^ ERROR no method named `b` found for reference `&dyn Foo` in the current scope [E0599]
61     foo.c();
62     //~^ ERROR no method named `c` found for reference `&dyn Foo` in the current scope [E0599]
63
64     let foo: &dyn Foo = bar;
65     foo.b();
66     //~^ ERROR no method named `b` found for reference `&dyn Foo` in the current scope [E0599]
67     foo.c();
68     //~^ ERROR no method named `c` found for reference `&dyn Foo` in the current scope [E0599]
69 }