]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.rs
1 //! Unless visibility is assumed, a transmutation should be rejected if the
2 //! destination type contains a private variant.
5 #![feature(transmutability)]
9 use std
::mem
::BikeshedIntrinsicFrom
;
11 pub fn is_transmutable
<Src
, Dst
, Context
>()
13 Dst
: BikeshedIntrinsicFrom
<Src
, Context
, false, false, false, false>
14 // visibility is NOT assumed ---------------------------------^^^^^
19 #[repr(C)] pub(in super) struct Zst;
21 #[repr(C)] pub(in super) struct Src {
22 pub(in super) field
: Zst
,
27 #[derive(Copy, Clone)]
28 #[repr(C)] pub(in super) struct Zst;
30 #[repr(C)] pub(in super) union Dst {
31 pub(self) field
: Zst
, // <- private variant
37 assert
::is_transmutable
::<src
::Src
, dst
::Dst
, Context
>(); //~ ERROR cannot be safely transmuted