Skip to content

Commit

Permalink
Change dest-prop/union.rs to be a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
CastilloDel committed Mar 10, 2024
1 parent 7cd670d commit 2e87b18
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
let mut _0: ();
let _1: main::Un;
let mut _2: u32;
let mut _3: u32;
let _3: ();
let mut _4: u32;
scope 1 {
debug un => _1;
scope 2 {
}
scope 4 (inlined std::mem::drop::<u32>) {
debug _x => _3;
}
}
scope 3 (inlined val) {
}

bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const 1_u32;
_1 = Un { us: const 1_u32 };
_2 = val() -> [return: bb1, unwind unreachable];
}

bb1: {
_1 = Un { us: move _2 };
StorageDead(_2);
StorageLive(_3);
_3 = (_1.0: u32);
StorageLive(_4);
_4 = (_1.0: u32);
_3 = std::mem::drop::<u32>(move _4) -> [return: bb2, unwind unreachable];
}

bb2: {
StorageDead(_4);
StorageDead(_3);
_0 = const ();
StorageDead(_1);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
let mut _0: ();
let _1: main::Un;
let mut _2: u32;
let mut _3: u32;
let _3: ();
let mut _4: u32;
scope 1 {
debug un => _1;
scope 2 {
}
scope 4 (inlined std::mem::drop::<u32>) {
debug _x => _3;
}
}
scope 3 (inlined val) {
}

bb0: {
StorageLive(_1);
StorageLive(_2);
_2 = const 1_u32;
_1 = Un { us: const 1_u32 };
_2 = val() -> [return: bb1, unwind continue];
}

bb1: {
_1 = Un { us: move _2 };
StorageDead(_2);
StorageLive(_3);
_3 = (_1.0: u32);
StorageLive(_4);
_4 = (_1.0: u32);
_3 = std::mem::drop::<u32>(move _4) -> [return: bb2, unwind continue];
}

bb2: {
StorageDead(_4);
StorageDead(_3);
_0 = const ();
StorageDead(_1);
return;
}
Expand Down
1 change: 1 addition & 0 deletions tests/mir-opt/dest-prop/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//! Tests that we can propagate into places that are projections into unions
//@ compile-flags: -Zunsound-mir-opts
//@ unit-test: DestinationPropagation
fn val() -> u32 {
1
}
Expand Down

0 comments on commit 2e87b18

Please sign in to comment.