]> git.lizzy.rs Git - rust.git/blob - src/test/ui/simd/size-align.rs
Rollup merge of #98775 - notriddle:notriddle/mobile-sidebar-scroll-lock, r=jsha
[rust.git] / src / test / ui / simd / size-align.rs
1 // run-pass
2 #![allow(deprecated)]
3
4
5 #![feature(repr_simd)]
6 #![allow(non_camel_case_types)]
7
8 use std::mem;
9
10 /// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec<T>` properly
11 /// Please consult the issue #20460
12 fn check<T>() {
13     assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0);
14     assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0);
15     assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0);
16 }
17
18 #[repr(simd)]
19 struct U8<const N: usize>([u8; N]);
20
21 #[repr(simd)]
22 struct I16<const N: usize>([i16; N]);
23
24 #[repr(simd)]
25 struct F32<const N: usize>([f32; N]);
26
27 #[repr(simd)]
28 struct Usize<const N: usize>([usize; N]);
29
30 #[repr(simd)]
31 struct Isize<const N: usize>([isize; N]);
32
33 fn main() {
34     check::<U8<2>>();
35     check::<U8<4>>();
36     check::<U8<8>>();
37
38     check::<I16<2>>();
39     check::<I16<4>>();
40     check::<I16<8>>();
41
42     check::<F32<2>>();
43     check::<F32<4>>();
44     check::<F32<8>>();
45
46     check::<Usize<2>>();
47     check::<Usize<4>>();
48     check::<Usize<8>>();
49
50     check::<Isize<2>>();
51     check::<Isize<4>>();
52     check::<Isize<8>>();
53 }