2023-07-13 23:32:36 +00:00
|
|
|
//@ check-fail
|
|
|
|
#![feature(generic_const_exprs, transmutability)]
|
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
mod assert {
|
2024-08-27 14:05:54 +00:00
|
|
|
use std::mem::{Assume, TransmuteFrom};
|
2023-07-13 23:32:36 +00:00
|
|
|
|
|
|
|
pub fn is_transmutable<
|
|
|
|
Src,
|
|
|
|
Dst,
|
|
|
|
const ASSUME_ALIGNMENT: bool,
|
|
|
|
const ASSUME_LIFETIMES: bool,
|
|
|
|
const ASSUME_SAFETY: bool,
|
|
|
|
const ASSUME_VALIDITY: bool,
|
|
|
|
>()
|
|
|
|
where
|
2024-08-27 14:05:54 +00:00
|
|
|
Dst: TransmuteFrom<
|
2023-07-13 23:32:36 +00:00
|
|
|
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;
|
|
|
|
|
2024-02-26 16:49:25 +00:00
|
|
|
assert::is_transmutable::<Src, Dst, false, false, { true }, false>();
|
2023-07-13 23:32:36 +00:00
|
|
|
}
|