]> git.proxmox.com Git - rustc.git/blob - src/test/ui/transmutability/abstraction/abstracted_assume.rs
New upstream version 1.64.0+dfsg1
[rustc.git] / src / test / ui / transmutability / abstraction / abstracted_assume.rs
1 // check-pass
2 //! The implementation should behave correctly when the `ASSUME` parameters are
3 //! provided indirectly through an abstraction.
4
5 #![crate_type = "lib"]
6 #![feature(transmutability)]
7 #![allow(dead_code, incomplete_features, non_camel_case_types)]
8
9 mod assert {
10 use std::mem::BikeshedIntrinsicFrom;
11
12 pub fn is_transmutable<
13 Src,
14 Dst,
15 Context,
16 const ASSUME_ALIGNMENT: bool,
17 const ASSUME_LIFETIMES: bool,
18 const ASSUME_VALIDITY: bool,
19 const ASSUME_VISIBILITY: bool,
20 >()
21 where
22 Dst: BikeshedIntrinsicFrom<
23 Src,
24 Context,
25 ASSUME_ALIGNMENT,
26 ASSUME_LIFETIMES,
27 ASSUME_VALIDITY,
28 ASSUME_VISIBILITY,
29 >,
30 {}
31 }
32
33 fn direct() {
34 struct Context;
35 #[repr(C)] struct Src;
36 #[repr(C)] struct Dst;
37
38 assert::is_transmutable::<Src, Dst, Context, false, false, false, false>();
39 }
40
41 fn via_const() {
42 struct Context;
43 #[repr(C)] struct Src;
44 #[repr(C)] struct Dst;
45
46 const FALSE: bool = false;
47
48 assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
49 }
50
51 fn via_associated_const() {
52 struct Context;
53 #[repr(C)] struct Src;
54 #[repr(C)] struct Dst;
55
56 trait Trait {
57 const FALSE: bool = true;
58 }
59
60 struct Ty;
61
62 impl Trait for Ty {}
63
64 assert::is_transmutable::<
65 Src,
66 Dst,
67 Context,
68 {Ty::FALSE},
69 {Ty::FALSE},
70 {Ty::FALSE},
71 {Ty::FALSE}
72 >();
73 }