Skip to content

account for c_enum_min_bits in multiple-reprs UI test #135778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/ui/structs-enums/multiple-reprs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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>()
}
Loading