From 709083127a942adffdae91f25125fe40e0a498dd Mon Sep 17 00:00:00 2001 From: CastilloDel Date: Sun, 10 Mar 2024 17:18:46 +0100 Subject: [PATCH] Change dest-prop/union.rs to be a unit test --- ...in.DestinationPropagation.panic-abort.diff | 24 ++++++++++++------- ...n.DestinationPropagation.panic-unwind.diff | 24 ++++++++++++------- tests/mir-opt/dest-prop/union.rs | 1 + 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index 0af3faf28f076..01a828aaecde7 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -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::) { - 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::(move _4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 0af3faf28f076..1ee6582147e09 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -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::) { - 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::(move _4) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_4); StorageDead(_3); + _0 = const (); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs index abd1f1b2c937a..c052decb25c62 100644 --- a/tests/mir-opt/dest-prop/union.rs +++ b/tests/mir-opt/dest-prop/union.rs @@ -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 }