blob: 7ea714f5cd3ee3b0ff6da73e8c1c25a16b8a5f19 [file]
//! Ensure that we do not dead-code-eliminate `size_of` calls. That might hide "type too big"
//! errors!
//@ build-fail (test needs codegen)
//@ compile-flags: -O
//@ normalize-stderr: "\d{5}\d*" -> "NUMBER"
//~? ERROR too big for the target
#![crate_type = "lib"]
const PTR_BITS_MINUS_1: usize = std::mem::size_of::<*const ()>() * 8 - 1;
#[unsafe(no_mangle)] // ensure this gets monomorphized
pub fn f() {
assert_valid_type::<[u32; 1 << PTR_BITS_MINUS_1]>();
}
pub fn assert_valid_type<T>() {
std::mem::size_of::<T>();
}