]> git.proxmox.com Git - rustc.git/blame - src/test/ui/transmutability/visibility/assume/should_accept_if_dst_has_unreachable_field.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / transmutability / visibility / assume / should_accept_if_dst_has_unreachable_field.rs
CommitLineData
064997fb
FG
1//! If visibility is assumed, a transmutation should be accepted even if the
2//! destination type contains an unreachable field (e.g., a public field with a
3//! private type). (This rule is distinct from type privacy, which still may
4//! forbid naming such types.)
5
6#![crate_type = "lib"]
7#![feature(transmutability)]
8#![allow(dead_code)]
9
10mod assert {
f2b60f7d 11 use std::mem::{Assume, BikeshedIntrinsicFrom};
064997fb
FG
12
13 pub fn is_transmutable<Src, Dst, Context>()
14 where
f2b60f7d
FG
15 Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
16 // safety IS assumed --------------------^^^^^^^^^^^^^^^^^^
064997fb
FG
17 {}
18}
19
20mod src {
21 #[repr(C)] pub(self) struct Zst;
22
23 #[repr(C)] pub(in super) struct Src {
24 pub(self) field: Zst,
25 }
26}
27
28mod dst {
29 #[repr(C)] pub(self) struct Zst; // <- unreachable type
30
31 #[repr(C)] pub(in super) struct Dst {
32 pub(in super) field: Zst, //~ ERROR private type
33 }
34}
35
36fn test() {
37 struct Context;
38 assert::is_transmutable::<src::Src, dst::Dst, Context>();
39}