From a710e1fb28d1a75eb7cb2261321c51cccf1c0bc8 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 20 Jan 2025 16:59:22 +0100 Subject: [PATCH] account for `c_enum_min_bits` in `multiple-reprs` UI test fixes #135777 --- tests/ui/structs-enums/multiple-reprs.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/ui/structs-enums/multiple-reprs.rs b/tests/ui/structs-enums/multiple-reprs.rs index 1528db126ae51..ce50b62ce47f7 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::(), 8); assert_eq!(size_of::(), align_size(10, align_of::())); assert_eq!(size_of::(), align_size(14, align_of::())); - assert_eq!(size_of::(), align_size(6 + size_of::(), align_of::())); + assert_eq!(size_of::(), align_size(6 + c_enum_min_size(), align_of::())); assert_eq!(size_of::(), 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::() +}