]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/transmute-size-mismatch-before-typeck.rs
Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_clif-2022-04-22
[rust.git] / src / test / ui / consts / transmute-size-mismatch-before-typeck.rs
1 // normalize-stderr-64bit "64 bits" -> "word size"
2 // normalize-stderr-32bit "32 bits" -> "word size"
3 // normalize-stderr-64bit "128 bits" -> "2 * word size"
4 // normalize-stderr-32bit "64 bits" -> "2 * word size"
5
6 fn main() {
7     match &b""[..] {
8         ZST => {} //~ ERROR could not evaluate constant pattern
9                   //~| ERROR could not evaluate constant pattern
10     }
11 }
12
13 const ZST: &[u8] = unsafe { std::mem::transmute(1usize) };
14 //~^ ERROR any use of this value will cause an error
15 //~| ERROR cannot transmute between types of different sizes
16 //~| WARN this was previously accepted by the compiler but is being phased out
17
18 // Once the `any use of this value will cause an error` disappears in this test, make sure to
19 // remove the `TransmuteSizeDiff` error variant and make its emitter site an assertion again.