2024-02-16 20:02:50 +00:00
|
|
|
//@ check-pass
|
2021-07-03 12:18:13 -04:00
|
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
#![feature(transmutability)]
|
|
|
|
|
#![feature(marker_trait_attr)]
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
|
|
mod assert {
|
2024-08-27 14:05:54 +00:00
|
|
|
use std::mem::{Assume, TransmuteFrom};
|
2021-07-03 12:18:13 -04:00
|
|
|
|
|
|
|
|
pub fn is_transmutable<Src, Dst>()
|
|
|
|
|
where
|
2024-08-27 14:05:54 +00:00
|
|
|
Dst: TransmuteFrom<Src, { Assume::SAFETY }>
|
2021-07-03 12:18:13 -04:00
|
|
|
{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn should_match_bool() {
|
|
|
|
|
#[derive(Copy, Clone)] #[repr(u8)] pub enum False { V = 0 }
|
|
|
|
|
#[derive(Copy, Clone)] #[repr(u8)] pub enum True { V = 1 }
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
pub union Bool {
|
|
|
|
|
pub f: False,
|
|
|
|
|
pub t: True,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert::is_transmutable::<Bool, bool>();
|
|
|
|
|
assert::is_transmutable::<bool, Bool>();
|
|
|
|
|
}
|