diff options
| author | Jakob Degen <jakob.e.degen@gmail.com> | 2022-11-27 18:48:04 -0800 |
|---|---|---|
| committer | Jakob Degen <jakob.e.degen@gmail.com> | 2022-11-29 19:26:04 -0800 |
| commit | 757810031764e4a0fce2a21eb5c8ba208ff7f6c1 (patch) | |
| tree | 68d4f71c67177588e70d145f87304884361c0c64 /src/test | |
| parent | a98254179b312f3d03c7ef57c53cdc590fc5c0b2 (diff) | |
| download | rust-757810031764e4a0fce2a21eb5c8ba208ff7f6c1.tar.gz rust-757810031764e4a0fce2a21eb5c8ba208ff7f6c1.zip | |
Support most constant kinds in custom mir
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/mir-opt/building/custom/consts.consts.built.after.mir | 22 | ||||
| -rw-r--r-- | src/test/mir-opt/building/custom/consts.rs | 23 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/mir-opt/building/custom/consts.consts.built.after.mir b/src/test/mir-opt/building/custom/consts.consts.built.after.mir new file mode 100644 index 00000000000..e384cdeb465 --- /dev/null +++ b/src/test/mir-opt/building/custom/consts.consts.built.after.mir @@ -0,0 +1,22 @@ +// MIR for `consts` after built + +fn consts() -> () { + let mut _0: (); // return place in scope 0 at $DIR/consts.rs:10:27: 10:27 + let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: i8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: fn() {consts::<10>}; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = const 5_u8; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + _2 = const _; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + _3 = const C; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + _4 = const _; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + _5 = consts::<10>; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + // mir::Constant + // + span: $DIR/consts.rs:16:18: 16:30 + // + literal: Const { ty: fn() {consts::<10>}, val: Value(<ZST>) } + return; // scope 0 at $DIR/consts.rs:+0:1: +0:26 + } +} diff --git a/src/test/mir-opt/building/custom/consts.rs b/src/test/mir-opt/building/custom/consts.rs new file mode 100644 index 00000000000..98b087f1e58 --- /dev/null +++ b/src/test/mir-opt/building/custom/consts.rs @@ -0,0 +1,23 @@ +#![feature(custom_mir, core_intrinsics, inline_const)] + +extern crate core; +use core::intrinsics::mir::*; + +const D: i32 = 5; + +// EMIT_MIR consts.consts.built.after.mir +#[custom_mir(dialect = "built")] +fn consts<const C: u32>() { + mir!({ + let _a = 5_u8; + let _b = const { 5_i8 }; + let _c = C; + let _d = D; + let _e = consts::<10>; + Return() + }) +} + +fn main() { + consts::<5>(); +} |
