]> git.proxmox.com Git - rustc.git/blob - tests/mir-opt/building/custom/consts.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / tests / mir-opt / building / custom / consts.rs
1 // skip-filecheck
2 #![feature(custom_mir, core_intrinsics, inline_const)]
3
4 extern crate core;
5 use core::intrinsics::mir::*;
6
7 const D: i32 = 5;
8
9 // EMIT_MIR consts.consts.built.after.mir
10 #[custom_mir(dialect = "built")]
11 fn consts<const C: u32>() {
12 mir!({
13 let _a = 5_u8;
14 let _b = const { 5_i8 };
15 let _c = C;
16 let _d = D;
17 let _e = consts::<10>;
18 Return()
19 })
20 }
21
22 static S: i32 = 0x05050505;
23 static mut T: i32 = 0x0a0a0a0a;
24 // EMIT_MIR consts.statics.built.after.mir
25 #[custom_mir(dialect = "built")]
26 fn statics() {
27 mir!({
28 let _a: &i32 = Static(S);
29 let _b: *mut i32 = StaticMut(T);
30 Return()
31 })
32 }
33
34 fn main() {
35 consts::<5>();
36 statics();
37 }