blob: 698492966adf3715c1b0bddcb95e31a89e3552d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
//@ run-pass
#[track_caller]
const fn assert_file_has_trailing_zero() {
let caller = core::panic::Location::caller();
let file_str = caller.file();
let file_cstr = caller.file_as_c_str();
if file_str.len() != file_cstr.count_bytes() {
panic!("mismatched lengths");
}
let trailing_byte: core::ffi::c_char = unsafe {
*file_cstr.as_ptr().offset(file_cstr.count_bytes() as _)
};
if trailing_byte != 0 {
panic!("trailing byte was nonzero")
}
}
#[allow(dead_code)]
const _: () = assert_file_has_trailing_zero();
fn main() {
assert_file_has_trailing_zero();
}
|