]> git.proxmox.com Git - rustc.git/blob - src/test/ui/transmutability/visibility/should_accept_if_src_has_private_variant.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / src / test / ui / transmutability / visibility / should_accept_if_src_has_private_variant.rs
1 // check-pass
2 //! The presence of a private variant in the source type does not affect
3 //! transmutability.
4
5 #![crate_type = "lib"]
6 #![feature(transmutability)]
7 #![allow(dead_code)]
8
9 mod assert {
10 use std::mem::BikeshedIntrinsicFrom;
11
12 pub fn is_transmutable<Src, Dst, Context>()
13 where
14 Dst: BikeshedIntrinsicFrom<Src, Context> // safety is NOT assumed
15 {}
16 }
17
18 mod src {
19 #[derive(Copy, Clone)]
20 #[repr(C)] pub(in super) struct Zst;
21
22 #[repr(C)] pub(in super) union Src {
23 pub(self) field: Zst, // <- private variant
24 }
25 }
26
27 mod dst {
28 #[repr(C)] pub(in super) struct Zst;
29
30 #[repr(C)] pub(in super) struct Dst {
31 pub(in super) field: Zst,
32 }
33 }
34
35 fn test() {
36 struct Context;
37 assert::is_transmutable::<src::Src, dst::Dst, Context>();
38 }