about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs
blob: 7ac619e09abf6f60faa1d530e44c2333cc2b460a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Validation and SB stop this too early.
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows

trait T1 {
    #[allow(dead_code)]
    fn method1(self: Box<Self>);
}
trait T2 {
    fn method2(self: Box<Self>);
}

impl T1 for i32 {
    fn method1(self: Box<Self>) {}
}

fn main() {
    let r = Box::new(0) as Box<dyn T1>;
    let r2: Box<dyn T2> = unsafe { std::mem::transmute(r) };
    r2.method2(); //~ERROR: using vtable for `T1` but `T2` was expected
}