]> git.lizzy.rs Git - rust.git/blob - src/test/ui/transmutability/malformed-program-gracefulness/wrong-type-assume.rs
Auto merge of #93455 - asquared31415:vec-zero-opts, r=thomcc
[rust.git] / src / test / ui / transmutability / malformed-program-gracefulness / wrong-type-assume.rs
1 //! The implementation must behave well if const values of wrong types are
2 //! provided.
3
4 #![crate_type = "lib"]
5 #![feature(adt_const_params)]
6 #![feature(generic_const_exprs)]
7 #![feature(transmutability)]
8 #![allow(dead_code, incomplete_features, non_camel_case_types)]
9
10 mod assert {
11     use std::mem::{Assume, BikeshedIntrinsicFrom};
12
13     pub fn is_transmutable<
14         Src,
15         Dst,
16         Context,
17         const ASSUME_ALIGNMENT: bool,
18         const ASSUME_LIFETIMES: bool,
19         const ASSUME_SAFETY: bool,
20         const ASSUME_VALIDITY: bool,
21     >()
22     where
23         Dst: BikeshedIntrinsicFrom<
24             Src,
25             Context,
26             { from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
27             //~^ ERROR E0080
28             //~| ERROR E0080
29             //~| ERROR E0080
30             //~| ERROR E0080
31         >,
32     {}
33
34     const fn from_options(
35         alignment: bool,
36         lifetimes: bool,
37         safety: bool,
38         validity: bool,
39     ) -> Assume {
40         Assume {
41             alignment,
42             lifetimes,
43             safety,
44             validity,
45         }
46     }
47 }
48
49 fn test() {
50     struct Context;
51     #[repr(C)] struct Src;
52     #[repr(C)] struct Dst;
53     assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>(); //~ ERROR mismatched types
54     assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>(); //~ ERROR mismatched types
55     assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>(); //~ ERROR mismatched types
56     assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>(); //~ ERROR mismatched types
57 }