File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( trait_upcasting) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ trait Foo : PartialEq < i32 > + std:: fmt:: Debug + Send + Sync {
5
+ fn a ( & self ) -> i32 {
6
+ 10
7
+ }
8
+
9
+ fn z ( & self ) -> i32 {
10
+ 11
11
+ }
12
+
13
+ fn y ( & self ) -> i32 {
14
+ 12
15
+ }
16
+ }
17
+
18
+ trait Bar : Foo {
19
+ fn b ( & self ) -> i32 {
20
+ 20
21
+ }
22
+
23
+ fn w ( & self ) -> i32 {
24
+ 21
25
+ }
26
+ }
27
+
28
+ trait Baz : Bar {
29
+ fn c ( & self ) -> i32 {
30
+ 30
31
+ }
32
+ }
33
+
34
+ impl Foo for i32 {
35
+ fn a ( & self ) -> i32 {
36
+ 100
37
+ }
38
+ }
39
+
40
+ impl Bar for i32 {
41
+ fn b ( & self ) -> i32 {
42
+ 200
43
+ }
44
+ }
45
+
46
+ impl Baz for i32 {
47
+ fn c ( & self ) -> i32 {
48
+ 300
49
+ }
50
+ }
51
+
52
+ fn main ( ) {
53
+ let baz: & dyn Baz = & 1 ;
54
+ let baz_fake: & dyn Bar = unsafe { std:: mem:: transmute ( baz) } ;
55
+ let _: & dyn std:: fmt:: Debug = baz_fake; //~ERROR upcast on a pointer whose vtable does not match its type
56
+ }
You can’t perform that action at this time.
0 commit comments