Skip to content

Commit 2e87b18

Browse files
committed
Change dest-prop/union.rs to be a unit test
1 parent 7cd670d commit 2e87b18

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff

+15-9
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@
55
let mut _0: ();
66
let _1: main::Un;
77
let mut _2: u32;
8-
let mut _3: u32;
8+
let _3: ();
9+
let mut _4: u32;
910
scope 1 {
1011
debug un => _1;
1112
scope 2 {
1213
}
13-
scope 4 (inlined std::mem::drop::<u32>) {
14-
debug _x => _3;
15-
}
16-
}
17-
scope 3 (inlined val) {
1814
}
1915

2016
bb0: {
2117
StorageLive(_1);
2218
StorageLive(_2);
23-
_2 = const 1_u32;
24-
_1 = Un { us: const 1_u32 };
19+
_2 = val() -> [return: bb1, unwind unreachable];
20+
}
21+
22+
bb1: {
23+
_1 = Un { us: move _2 };
2524
StorageDead(_2);
2625
StorageLive(_3);
27-
_3 = (_1.0: u32);
26+
StorageLive(_4);
27+
_4 = (_1.0: u32);
28+
_3 = std::mem::drop::<u32>(move _4) -> [return: bb2, unwind unreachable];
29+
}
30+
31+
bb2: {
32+
StorageDead(_4);
2833
StorageDead(_3);
34+
_0 = const ();
2935
StorageDead(_1);
3036
return;
3137
}

tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff

+15-9
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@
55
let mut _0: ();
66
let _1: main::Un;
77
let mut _2: u32;
8-
let mut _3: u32;
8+
let _3: ();
9+
let mut _4: u32;
910
scope 1 {
1011
debug un => _1;
1112
scope 2 {
1213
}
13-
scope 4 (inlined std::mem::drop::<u32>) {
14-
debug _x => _3;
15-
}
16-
}
17-
scope 3 (inlined val) {
1814
}
1915

2016
bb0: {
2117
StorageLive(_1);
2218
StorageLive(_2);
23-
_2 = const 1_u32;
24-
_1 = Un { us: const 1_u32 };
19+
_2 = val() -> [return: bb1, unwind continue];
20+
}
21+
22+
bb1: {
23+
_1 = Un { us: move _2 };
2524
StorageDead(_2);
2625
StorageLive(_3);
27-
_3 = (_1.0: u32);
26+
StorageLive(_4);
27+
_4 = (_1.0: u32);
28+
_3 = std::mem::drop::<u32>(move _4) -> [return: bb2, unwind continue];
29+
}
30+
31+
bb2: {
32+
StorageDead(_4);
2833
StorageDead(_3);
34+
_0 = const ();
2935
StorageDead(_1);
3036
return;
3137
}

tests/mir-opt/dest-prop/union.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
33
//! Tests that we can propagate into places that are projections into unions
44
//@ compile-flags: -Zunsound-mir-opts
5+
//@ unit-test: DestinationPropagation
56
fn val() -> u32 {
67
1
78
}

0 commit comments

Comments
 (0)