23ab1bda92
Migrate to a simplified safety analysis that does not use visibility. Closes https://github.com/rust-lang/project-safe-transmute/issues/15
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
//@ check-fail
|
|
#![feature(generic_const_exprs, transmutability)]
|
|
#![allow(incomplete_features)]
|
|
|
|
mod assert {
|
|
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
|
|
|
pub fn is_transmutable<
|
|
Src,
|
|
Dst,
|
|
const ASSUME_ALIGNMENT: bool,
|
|
const ASSUME_LIFETIMES: bool,
|
|
const ASSUME_SAFETY: bool,
|
|
const ASSUME_VALIDITY: bool,
|
|
>()
|
|
where
|
|
Dst: BikeshedIntrinsicFrom<
|
|
Src,
|
|
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
|
|
>,
|
|
{}
|
|
|
|
// This should not cause an ICE
|
|
const fn from_options(
|
|
, //~ ERROR expected parameter name, found `,`
|
|
, //~ ERROR expected parameter name, found `,`
|
|
, //~ ERROR expected parameter name, found `,`
|
|
, //~ ERROR expected parameter name, found `,`
|
|
) -> Assume {} //~ ERROR mismatched types
|
|
}
|
|
|
|
fn main() {
|
|
#[repr(C)] struct Src;
|
|
#[repr(C)] struct Dst;
|
|
|
|
assert::is_transmutable::<Src, Dst, false, false, { true }, false>();
|
|
}
|