diff options
| author | Jorge Aparicio <jorge.aparicio@ferrous-systems.com> | 2025-01-20 16:59:22 +0100 |
|---|---|---|
| committer | Jorge Aparicio <jorge.aparicio@ferrous-systems.com> | 2025-01-20 17:04:49 +0100 |
| commit | a710e1fb28d1a75eb7cb2261321c51cccf1c0bc8 (patch) | |
| tree | 283d85d0d4e7009cab448d987a75a62af153f9f8 /tests/ui/structs-enums | |
| parent | b5741a36a897dd93936d31ea0c1688f1399a2e06 (diff) | |
| download | rust-a710e1fb28d1a75eb7cb2261321c51cccf1c0bc8.tar.gz rust-a710e1fb28d1a75eb7cb2261321c51cccf1c0bc8.zip | |
account for `c_enum_min_bits` in `multiple-reprs` UI test
fixes #135777
Diffstat (limited to 'tests/ui/structs-enums')
| -rw-r--r-- | tests/ui/structs-enums/multiple-reprs.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/ui/structs-enums/multiple-reprs.rs b/tests/ui/structs-enums/multiple-reprs.rs index 1528db126ae..ce50b62ce47 100644 --- a/tests/ui/structs-enums/multiple-reprs.rs +++ b/tests/ui/structs-enums/multiple-reprs.rs @@ -69,7 +69,7 @@ pub fn main() { assert_eq!(size_of::<E4>(), 8); assert_eq!(size_of::<E5>(), align_size(10, align_of::<u32>())); assert_eq!(size_of::<E6>(), align_size(14, align_of::<u64>())); - assert_eq!(size_of::<E7>(), align_size(6 + size_of::<c_int>(), align_of::<c_int>())); + assert_eq!(size_of::<E7>(), align_size(6 + c_enum_min_size(), align_of::<c_int>())); assert_eq!(size_of::<p0f_api_query>(), 21); } @@ -80,3 +80,13 @@ fn align_size(size: usize, align: usize) -> usize { size } } + +// this is `TargetOptions.c_enum_min_bits` which is not available as a `cfg` value so we retrieve +// the value at runtime. On most targets this is `sizeof(c_int)` but on `thumb*-none` is 1 byte +fn c_enum_min_size() -> usize { + #[repr(C)] + enum E { + A, + } + size_of::<E>() +} |
