]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-27060-rpass.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / src / test / ui / issues / 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(safe_packed_borrows)]
12 fn main() {
13 let good = Good { data: &0, data2: [&0, &0], aligned: [0; 32] };
14
15 unsafe {
16 let _ = &good.data; // ok
17 let _ = &good.data2[0]; // ok
18 }
19
20 let _ = &good.data;
21 let _ = &good.data2[0];
22 let _ = &*good.data; // ok, behind a pointer
23 let _ = &good.aligned; // ok, has align 1
24 let _ = &good.aligned[2]; // ok, has align 1
25 }