]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/transmute-size-mismatch-before-typeck.rs
Check that value is explicitly none
[rust.git] / src / test / ui / consts / transmute-size-mismatch-before-typeck.rs
1 #![feature(const_transmute)]
2
3 // normalize-stderr-64bit "64 bits" -> "word size"
4 // normalize-stderr-32bit "32 bits" -> "word size"
5 // normalize-stderr-64bit "128 bits" -> "2 * word size"
6 // normalize-stderr-32bit "64 bits" -> "2 * word size"
7
8 fn main() {
9     match &b""[..] {
10         ZST => {} //~ ERROR could not evaluate constant pattern
11                   //~| ERROR could not evaluate constant pattern
12     }
13 }
14
15 const ZST: &[u8] = unsafe { std::mem::transmute(1usize) };
16 //~^ ERROR any use of this value will cause an error
17 //~| ERROR cannot transmute between types of different sizes
18
19 // Once the `any use of this value will cause an error` disappears in this test, make sure to
20 // remove the `TransmuteSizeDiff` error variant and make its emitter site an assertion again.