about summary refs log tree commit diff
path: root/tests/ui/transmutability/malformed-program-gracefulness/unknown_dst_field.rs
blob: 081d1bf11ec0402b71da97b2f091d0b8b3acb5ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// An unknown destination type should be gracefully handled.

#![crate_type = "lib"]
#![feature(transmutability)]
#![allow(incomplete_features)]

mod assert {
    use std::mem::TransmuteFrom;

    pub fn is_transmutable<Src, Dst>()
    where
        Dst: TransmuteFrom<Src>
    {}
}

fn should_gracefully_handle_unknown_dst_field() {
    #[repr(C)] struct Src;
    #[repr(C)] struct Dst(Missing); //~ ERROR cannot find type
    assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
}

fn should_gracefully_handle_unknown_dst_ref_field() {
    #[repr(C)] struct Src(&'static Src);
    #[repr(C)] struct Dst(&'static Missing); //~ ERROR cannot find type
    assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
}