]> git.lizzy.rs Git - rust.git/blob - src/test/ui/packed/issue-27060-rpass.rs
Rollup merge of #95534 - jyn514:std-mem-copy, r=joshtriplett
[rust.git] / src / test / ui / packed / issue-27060-rpass.rs
1 // run-pass
2 #![allow(dead_code)]
3 #[repr(packed)]
4 pub struct Good {
5     data: &'static u32,
6     data2: [&'static u32; 2],
7     aligned: [u8; 32],
8 }
9
10 // kill this test when that turns to a hard error
11 #[allow(unaligned_references)]
12 fn main() {
13     let good = Good { data: &0, data2: [&0, &0], aligned: [0; 32] };
14
15     let _ = &good.data; // ok
16     let _ = &good.data2[0]; // ok
17
18     let _ = &good.data;
19     let _ = &good.data2[0];
20     let _ = &*good.data; // ok, behind a pointer
21     let _ = &good.aligned; // ok, has align 1
22     let _ = &good.aligned[2]; // ok, has align 1
23 }