summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/dataflow-const-prop/enum.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/dataflow-const-prop/enum.rs')
-rw-r--r--tests/mir-opt/dataflow-const-prop/enum.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs
index 79a20d7ef..5a10e9e88 100644
--- a/tests/mir-opt/dataflow-const-prop/enum.rs
+++ b/tests/mir-opt/dataflow-const-prop/enum.rs
@@ -1,9 +1,11 @@
// unit-test: DataflowConstProp
+// EMIT_MIR_FOR_EACH_BIT_WIDTH
#![feature(custom_mir, core_intrinsics, rustc_attrs)]
use std::intrinsics::mir::*;
+#[derive(Copy, Clone)]
enum E {
V1(i32),
V2(i32)
@@ -15,6 +17,24 @@ fn simple() {
let x = match e { E::V1(x) => x, E::V2(x) => x };
}
+// EMIT_MIR enum.constant.DataflowConstProp.diff
+fn constant() {
+ const C: E = E::V1(0);
+ let e = C;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+}
+
+// EMIT_MIR enum.statics.DataflowConstProp.diff
+fn statics() {
+ static C: E = E::V1(0);
+ let e = C;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+
+ static RC: &E = &E::V2(4);
+ let e = RC;
+ let x = match e { E::V1(x) => x, E::V2(x) => x };
+}
+
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
struct NonZeroUsize(usize);
@@ -63,6 +83,8 @@ fn multiple(x: bool, i: u8) {
fn main() {
simple();
+ constant();
+ statics();
mutate_discriminant();
multiple(false, 5);
}