]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/validate_never_arrays.rs
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
[rust.git] / tests / ui / consts / validate_never_arrays.rs
1 // Strip out raw byte dumps to make comparison platform-independent:
2 // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
3 // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
4 #![feature(never_type)]
5
6 const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior
7 const _: &[!; 0] = unsafe { &*(1_usize as *const [!; 0]) }; // ok
8 const _: &[!] = unsafe { &*(1_usize as *const [!; 0]) }; // ok
9 const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior
10 const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; //~ ERROR undefined behavior
11
12 fn main() {}