diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/union/union-align.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/union/union-align.rs')
-rw-r--r-- | src/test/ui/union/union-align.rs | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/test/ui/union/union-align.rs b/src/test/ui/union/union-align.rs deleted file mode 100644 index 6a44f27db..000000000 --- a/src/test/ui/union/union-align.rs +++ /dev/null @@ -1,65 +0,0 @@ -// run-pass -// revisions: mirunsafeck thirunsafeck -// [thirunsafeck]compile-flags: -Z thir-unsafeck - -#![allow(dead_code)] - -use std::mem::{size_of, size_of_val, align_of, align_of_val}; - -#[repr(align(16))] -pub union U16 { - a: u8, - b: u32 -} - -fn main() { - assert_eq!(align_of::<U16>(), 16); - assert_eq!(size_of::<U16>(), 16); - let u = U16 { a: 10 }; - unsafe { - assert_eq!(align_of_val(&u.a), 1); - assert_eq!(size_of_val(&u.a), 1); - assert_eq!(u.a, 10); - } - - let u = U16 { b: 11 }; - unsafe { - assert_eq!(align_of_val(&u.b), 4); - assert_eq!(size_of_val(&u.b), 4); - assert_eq!(u.b, 11); - } - - hybrid::check_hybrid(); -} - -mod hybrid { - use std::mem::{size_of, align_of}; - - #[repr(align(16))] - #[derive(Copy, Clone)] - struct S1 { - a: u16, - b: u8, - } - - #[repr(align(32))] - union U { - s: S1, - c: u16, - } - - #[repr(align(64))] - struct S2 { - d: u8, - u: U, - } - - pub fn check_hybrid() { - assert_eq!(align_of::<S1>(), 16); - assert_eq!(size_of::<S1>(), 16); - assert_eq!(align_of::<U>(), 32); - assert_eq!(size_of::<U>(), 32); - assert_eq!(align_of::<S2>(), 64); - assert_eq!(size_of::<S2>(), 64); - } -} |