rust/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.rs
Bryan Garza f4cf8f65a5 Safe Transmute: Refactor error handling and Answer type
- Create `Answer` type that is not just a type alias of `Result`
- Remove a usage of `map_layouts` to make the code easier to read
- Don't hide errors related to Unknown Layout when computing transmutability
2023-06-12 16:56:21 -07:00

23 lines
621 B
Rust

// 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 struct Context;
pub fn is_transmutable<Src, Dst, Context>()
where
Dst: BikeshedIntrinsicFrom<Src, Context>
{}
}
fn should_gracefully_handle_unknown_dst_field() {
struct Context;
#[repr(C)] struct Src;
#[repr(C)] struct Dst(Missing); //~ cannot find type
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
}