forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunknown_src_field.rs
More file actions
26 lines (21 loc) · 797 Bytes
/
Copy pathunknown_src_field.rs
File metadata and controls
26 lines (21 loc) · 797 Bytes
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(dead_code, incomplete_features, non_camel_case_types)]
mod assert {
use std::mem::BikeshedIntrinsicFrom;
pub fn is_transmutable<Src, Dst>()
where
Dst: BikeshedIntrinsicFrom<Src>
{}
}
fn should_gracefully_handle_unknown_src_field() {
#[repr(C)] struct Src(Missing); //~ cannot find type
#[repr(C)] struct Dst();
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
}
fn should_gracefully_handle_unknown_src_ref_field() {
#[repr(C)] struct Src(&'static Missing); //~ cannot find type
#[repr(C)] struct Dst(&'static Dst);
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
}