]> git.proxmox.com Git - rustc.git/blob - src/test/mir-opt/const_prop/invalid_constant.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / mir-opt / const_prop / invalid_constant.rs
1 // Verify that we can pretty print invalid constants.
2
3 #![feature(adt_const_params)]
4 #![feature(inline_const)]
5 #![allow(incomplete_features)]
6
7 #[derive(Copy, Clone)]
8 #[repr(u32)]
9 enum E { A, B, C }
10
11 #[derive(Copy, Clone)]
12 enum Empty {}
13
14 // EMIT_MIR invalid_constant.main.ConstProp.diff
15 fn main() {
16 // An invalid char.
17 union InvalidChar {
18 int: u32,
19 chr: char,
20 }
21 let _invalid_char = const { InvalidChar { int: 0x110001 } };
22
23 // An enum with an invalid tag. Regression test for #93688.
24 union InvalidTag {
25 int: u32,
26 e: E,
27 }
28 let _invalid_tag = [InvalidTag { int: 4 }];
29
30 // An enum without variants. Regression test for #94073.
31 union NoVariants {
32 int: u32,
33 empty: Empty,
34 }
35 let _enum_without_variants = [NoVariants { int: 0 }];
36
37 // A non-UTF-8 string slice. Regression test for #75763 and #78520.
38 struct Str<const S: &'static str>;
39 let _non_utf8_str: Str::<{
40 unsafe { std::mem::transmute::<&[u8], &str>(&[0xC0, 0xC1, 0xF5]) }
41 }>;
42 }