about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-25 06:14:35 +0000
committerbors <bors@rust-lang.org>2023-02-25 06:14:35 +0000
commit313219c0b6bacabe0fc72a8eb3912b8fc08b9bdb (patch)
treee70382a7e97ea8af4644d043ed705067115390a9 /tests
parent6ffabf3c8f2ed81d0248c54365445f28bd9507e5 (diff)
parent2a70524397728e4d13e494667fc4865af42c879b (diff)
downloadrust-313219c0b6bacabe0fc72a8eb3912b8fc08b9bdb.tar.gz
rust-313219c0b6bacabe0fc72a8eb3912b8fc08b9bdb.zip
Auto merge of #106430 - tmiasko:rm-dead-unwinds, r=cjgillot
Remove dead unwinds before drop elaboration

As a part of drop elaboration, we identify dead unwinds, i.e., unwind
edges on a drop terminators which are known to be unreachable, because
there is no need to drop anything.

Previously, the data flow framework was informed about the dead unwinds,
and it assumed those edges are absent from MIR. Unfortunately, the data
flow framework wasn't consistent in maintaining this assumption.

In particular, if a block was reachable only through a dead unwind edge,
its state was propagated to other blocks still. This became an issue in
the context of change removes DropAndReplace terminator, since it
introduces initialization into cleanup blocks.

To avoid this issue, remove unreachable unwind edges before the drop
elaboration, and elaborate only blocks that remain reachable.

cc `@Zeegomo`
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir70
-rw-r--r--tests/mir-opt/issue_41110.main.ElaborateDrops.diff75
-rw-r--r--tests/mir-opt/issue_41110.rs4
-rw-r--r--tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir101
-rw-r--r--tests/mir-opt/issue_41110.test.ElaborateDrops.diff109
-rw-r--r--tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir152
-rw-r--r--tests/mir-opt/issue_41888.main.ElaborateDrops.diff158
-rw-r--r--tests/mir-opt/issue_41888.rs2
8 files changed, 345 insertions, 326 deletions
diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir
deleted file mode 100644
index c2ea3ac502f..00000000000
--- a/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir
+++ /dev/null
@@ -1,70 +0,0 @@
-// MIR for `main` after ElaborateDrops
-
-fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11
-    let _1: ();                          // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-    let mut _2: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-    let mut _3: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
-    let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
-    let mut _5: bool;                    // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-    scope 1 {
-        debug x => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
-    }
-
-    bb0: {
-        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-        StorageLive(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-        _5 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-        _2 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-        StorageLive(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
-        StorageLive(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
-        _4 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
-        _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
-                                         // mir::Constant
-                                         // + span: $DIR/issue_41110.rs:8:23: 8:25
-                                         // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(<ZST>) }
-    }
-
-    bb1: {
-        StorageDead(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
-        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
-        _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
-                                         // mir::Constant
-                                         // + span: $DIR/issue_41110.rs:8:15: 8:20
-                                         // + literal: Const { ty: fn(S, S) {S::other}, val: Value(<ZST>) }
-    }
-
-    bb2: {
-        StorageDead(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-        _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-        StorageDead(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-        _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2
-        return;                          // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2
-    }
-
-    bb3 (cleanup): {
-        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-    }
-
-    bb4 (cleanup): {
-        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
-    }
-
-    bb5 (cleanup): {
-        goto -> bb8;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-    }
-
-    bb6 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2
-    }
-
-    bb7 (cleanup): {
-        drop(_2) -> bb6;                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-    }
-
-    bb8 (cleanup): {
-        switchInt(_5) -> [0: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
-    }
-}
diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.diff b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff
new file mode 100644
index 00000000000..7ac75b51a37
--- /dev/null
+++ b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff
@@ -0,0 +1,75 @@
+- // MIR for `main` before ElaborateDrops
++ // MIR for `main` after ElaborateDrops
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11
+      let _1: ();                          // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+      let mut _2: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+      let mut _3: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
+      let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
++     let mut _5: bool;                    // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+      scope 1 {
+          debug x => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
+      }
+  
+      bb0: {
++         _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+          StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+          StorageLive(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
++         _5 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+          _2 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+          StorageLive(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
+          StorageLive(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
+          _4 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22
+          _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27
+                                           // mir::Constant
+                                           // + span: $DIR/issue_41110.rs:8:23: 8:25
+                                           // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(<ZST>) }
+      }
+  
+      bb1: {
+          StorageDead(_4);                 // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
++         _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
+          _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28
+                                           // mir::Constant
+                                           // + span: $DIR/issue_41110.rs:8:15: 8:20
+                                           // + literal: Const { ty: fn(S, S) {S::other}, val: Value(<ZST>) }
+      }
+  
+      bb2: {
+          StorageDead(_3);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
++         _5 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+          StorageDead(_2);                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+          _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2
+          StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2
+          return;                          // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2
+      }
+  
+      bb3 (cleanup): {
+-         drop(_3) -> bb5;                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
++         goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+      }
+  
+      bb4 (cleanup): {
+-         drop(_4) -> bb5;                 // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
++         goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27
+      }
+  
+      bb5 (cleanup): {
+-         drop(_2) -> bb6;                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
++         goto -> bb8;                     // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+      }
+  
+      bb6 (cleanup): {
+          resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2
++     }
++ 
++     bb7 (cleanup): {
++         drop(_2) -> bb6;                 // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
++     }
++ 
++     bb8 (cleanup): {
++         switchInt(_5) -> [0: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28
+      }
+  }
+  
diff --git a/tests/mir-opt/issue_41110.rs b/tests/mir-opt/issue_41110.rs
index 638dc601ec8..e1067ce53e4 100644
--- a/tests/mir-opt/issue_41110.rs
+++ b/tests/mir-opt/issue_41110.rs
@@ -3,14 +3,14 @@
 // check that we don't emit multiple drop flags when they are not needed.
 
 
-// EMIT_MIR issue_41110.main.ElaborateDrops.after.mir
+// EMIT_MIR issue_41110.main.ElaborateDrops.diff
 fn main() {
     let x = S.other(S.id());
 }
 
 // no_mangle to make sure this gets instantiated even in an executable.
 #[no_mangle]
-// EMIT_MIR issue_41110.test.ElaborateDrops.after.mir
+// EMIT_MIR issue_41110.test.ElaborateDrops.diff
 pub fn test() {
     let u = S;
     let mut v = S;
diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir
deleted file mode 100644
index 82989c3f071..00000000000
--- a/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir
+++ /dev/null
@@ -1,101 +0,0 @@
-// MIR for `test` after ElaborateDrops
-
-fn test() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15
-    let _1: S;                           // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-    let _3: ();                          // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12
-    let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11
-    let mut _5: S;                       // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10
-    let mut _6: bool;                    // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-    scope 1 {
-        debug u => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
-        let mut _2: S;                   // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
-        scope 2 {
-            debug v => _2;               // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14
-        }
-    }
-
-    bb0: {
-        _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
-        _6 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-        _1 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
-        StorageLive(_2);                 // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
-        _2 = S;                          // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18
-        StorageLive(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
-        StorageLive(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
-        _4 = move _2;                    // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
-        _3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
-                                         // mir::Constant
-                                         // + span: $DIR/issue_41110.rs:17:5: 17:9
-                                         // + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(<ZST>) }
-    }
-
-    bb1: {
-        StorageDead(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
-        StorageDead(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13
-        StorageLive(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-        _6 = const false;                // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-        _5 = move _1;                    // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-        goto -> bb12;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
-    }
-
-    bb2: {
-        goto -> bb3;                     // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-    }
-
-    bb3: {
-        StorageDead(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-        _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2
-        drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-
-    bb4: {
-        StorageDead(_2);                 // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
-        goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-
-    bb5: {
-        _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-        return;                          // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2
-    }
-
-    bb6 (cleanup): {
-        goto -> bb8;                     // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
-    }
-
-    bb7 (cleanup): {
-        goto -> bb8;                     // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
-    }
-
-    bb8 (cleanup): {
-        goto -> bb9;                     // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-
-    bb9 (cleanup): {
-        goto -> bb14;                    // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-
-    bb10 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2
-    }
-
-    bb11 (cleanup): {
-        _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
-        goto -> bb6;                     // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
-    }
-
-    bb12: {
-        _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
-        goto -> bb2;                     // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
-    }
-
-    bb13 (cleanup): {
-        drop(_1) -> bb10;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-
-    bb14 (cleanup): {
-        switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
-    }
-}
diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff
new file mode 100644
index 00000000000..79e3d073be5
--- /dev/null
+++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff
@@ -0,0 +1,109 @@
+- // MIR for `test` before ElaborateDrops
++ // MIR for `test` after ElaborateDrops
+  
+  fn test() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15
+      let _1: S;                           // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+      let _3: ();                          // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12
+      let mut _4: S;                       // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11
+      let mut _5: S;                       // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10
++     let mut _6: bool;                    // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+      scope 1 {
+          debug u => _1;                   // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10
+          let mut _2: S;                   // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
+          scope 2 {
+              debug v => _2;               // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14
+          }
+      }
+  
+      bb0: {
++         _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
+          StorageLive(_1);                 // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10
++         _6 = const true;                 // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+          _1 = S;                          // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14
+          StorageLive(_2);                 // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14
+          _2 = S;                          // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18
+          StorageLive(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
+          StorageLive(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
+          _4 = move _2;                    // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11
+          _3 = std::mem::drop::<S>(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12
+                                           // mir::Constant
+                                           // + span: $DIR/issue_41110.rs:17:5: 17:9
+                                           // + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(<ZST>) }
+      }
+  
+      bb1: {
+          StorageDead(_4);                 // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
+          StorageDead(_3);                 // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13
+          StorageLive(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
++         _6 = const false;                // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+          _5 = move _1;                    // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+-         replace(_2 <- move _5) -> [return: bb2, unwind: bb6]; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
++         goto -> bb12;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
+      }
+  
+      bb2: {
+-         drop(_5) -> [return: bb3, unwind: bb8]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
++         goto -> bb3;                     // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+      }
+  
+      bb3: {
+          StorageDead(_5);                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+          _0 = const ();                   // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2
+          drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
+      }
+  
+      bb4: {
+          StorageDead(_2);                 // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
+-         drop(_1) -> bb5;                 // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
++         goto -> bb5;                     // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+      }
+  
+      bb5: {
++         _6 = const false;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+          StorageDead(_1);                 // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+          return;                          // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2
+      }
+  
+      bb6 (cleanup): {
+          drop(_5) -> bb8;                 // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10
+      }
+  
+      bb7 (cleanup): {
+-         drop(_4) -> bb8;                 // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
++         goto -> bb8;                     // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12
+      }
+  
+      bb8 (cleanup): {
+-         drop(_2) -> bb9;                 // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
++         goto -> bb9;                     // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2
+      }
+  
+      bb9 (cleanup): {
+-         drop(_1) -> bb10;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
++         goto -> bb14;                    // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+      }
+  
+      bb10 (cleanup): {
+          resume;                          // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2
++     }
++ 
++     bb11 (cleanup): {
++         _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
++         goto -> bb10;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
++     }
++ 
++     bb12: {
++         _2 = move _5;                    // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
++         goto -> bb2;                     // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6
++     }
++ 
++     bb13 (cleanup): {
++         drop(_1) -> bb10;                // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
++     }
++ 
++     bb14 (cleanup): {
++         switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2
+      }
+  }
+  
diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir
deleted file mode 100644
index 00504273245..00000000000
--- a/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir
+++ /dev/null
@@ -1,152 +0,0 @@
-// MIR for `main` after ElaborateDrops
-
-fn main() -> () {
-    let mut _0: ();                      // return place in scope 0 at $DIR/issue_41888.rs:+0:11: +0:11
-    let _1: E;                           // in scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
-    let mut _2: bool;                    // in scope 0 at $DIR/issue_41888.rs:+2:8: +2:14
-    let mut _3: E;                       // in scope 0 at $DIR/issue_41888.rs:+3:13: +3:20
-    let mut _4: K;                       // in scope 0 at $DIR/issue_41888.rs:+3:18: +3:19
-    let mut _5: isize;                   // in scope 0 at $DIR/issue_41888.rs:+4:16: +4:24
-    let mut _7: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    let mut _8: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    let mut _9: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    let mut _10: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    let mut _11: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    scope 1 {
-        debug e => _1;                   // in scope 1 at $DIR/issue_41888.rs:+1:9: +1:10
-        scope 2 {
-            debug _k => _6;              // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
-            let _6: K;                   // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
-        }
-    }
-
-    bb0: {
-        _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
-        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
-        _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
-        StorageLive(_1);                 // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
-        StorageLive(_2);                 // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
-        _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
-                                         // mir::Constant
-                                         // + span: $DIR/issue_41888.rs:8:8: 8:12
-                                         // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) }
-    }
-
-    bb1: {
-        switchInt(move _2) -> [0: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
-    }
-
-    bb2: {
-        StorageLive(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
-        StorageLive(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
-        _4 = K;                          // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
-        _3 = E::F(move _4);              // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
-        StorageDead(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
-        goto -> bb14;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-    }
-
-    bb3: {
-        goto -> bb4;                     // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
-    }
-
-    bb4: {
-        StorageDead(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
-        _5 = discriminant(_1);           // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
-        switchInt(move _5) -> [0: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
-    }
-
-    bb5: {
-        StorageLive(_6);                 // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
-        _9 = const false;                // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
-        _6 = move ((_1 as F).0: K);      // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
-        _0 = const ();                   // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10
-        StorageDead(_6);                 // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10
-        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
-    }
-
-    bb6: {
-        _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10
-        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
-    }
-
-    bb7: {
-        _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6
-        goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6
-    }
-
-    bb8: {
-        StorageDead(_2);                 // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6
-        goto -> bb20;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb9: {
-        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        StorageDead(_1);                 // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        return;                          // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2
-    }
-
-    bb10 (cleanup): {
-        goto -> bb11;                    // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
-    }
-
-    bb11 (cleanup): {
-        goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb12 (cleanup): {
-        resume;                          // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2
-    }
-
-    bb13 (cleanup): {
-        _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        goto -> bb10;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-    }
-
-    bb14: {
-        _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-        goto -> bb3;                     // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
-    }
-
-    bb15: {
-        _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        goto -> bb9;                     // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb16 (cleanup): {
-        goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb17: {
-        drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb18 (cleanup): {
-        drop(_1) -> bb12;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb19: {
-        _10 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        switchInt(move _10) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb20: {
-        switchInt(_7) -> [0: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb21 (cleanup): {
-        _11 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-        switchInt(move _11) -> [0: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-
-    bb22 (cleanup): {
-        switchInt(_7) -> [0: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
-    }
-}
diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff
new file mode 100644
index 00000000000..257f0b1e6e8
--- /dev/null
+++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff
@@ -0,0 +1,158 @@
+- // MIR for `main` before ElaborateDrops
++ // MIR for `main` after ElaborateDrops
+  
+  fn main() -> () {
+      let mut _0: ();                      // return place in scope 0 at $DIR/issue_41888.rs:+0:11: +0:11
+      let _1: E;                           // in scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+      let mut _2: bool;                    // in scope 0 at $DIR/issue_41888.rs:+2:8: +2:14
+      let mut _3: E;                       // in scope 0 at $DIR/issue_41888.rs:+3:13: +3:20
+      let mut _4: K;                       // in scope 0 at $DIR/issue_41888.rs:+3:18: +3:19
+      let mut _5: isize;                   // in scope 0 at $DIR/issue_41888.rs:+4:16: +4:24
++     let mut _7: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     let mut _8: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     let mut _9: bool;                    // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     let mut _10: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     let mut _11: isize;                  // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+      scope 1 {
+          debug e => _1;                   // in scope 1 at $DIR/issue_41888.rs:+1:9: +1:10
+          scope 2 {
+              debug _k => _6;              // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+              let _6: K;                   // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+          }
+      }
+  
+      bb0: {
++         _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
++         _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
++         _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+          StorageLive(_1);                 // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10
+          StorageLive(_2);                 // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
+          _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
+                                           // mir::Constant
+                                           // + span: $DIR/issue_41888.rs:8:8: 8:12
+                                           // + literal: Const { ty: fn() -> bool {cond}, val: Value(<ZST>) }
+      }
+  
+      bb1: {
+          switchInt(move _2) -> [0: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14
+      }
+  
+      bb2: {
+          StorageLive(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
+          StorageLive(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
+          _4 = K;                          // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19
+          _3 = E::F(move _4);              // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20
+          StorageDead(_4);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+-         replace(_1 <- move _3) -> [return: bb3, unwind: bb10]; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         goto -> bb14;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
+      }
+  
+      bb3: {
+-         drop(_3) -> [return: bb4, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
++         goto -> bb4;                     // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+      }
+  
+      bb4: {
+          StorageDead(_3);                 // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+          _5 = discriminant(_1);           // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
+          switchInt(move _5) -> [0: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24
+      }
+  
+      bb5: {
+          StorageLive(_6);                 // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
++         _9 = const false;                // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+          _6 = move ((_1 as F).0: K);      // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23
+          _0 = const ();                   // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10
+          StorageDead(_6);                 // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10
+          goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
+      }
+  
+      bb6: {
+          _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10
+          goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10
+      }
+  
+      bb7: {
+          _0 = const ();                   // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6
+          goto -> bb8;                     // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6
+      }
+  
+      bb8: {
+          StorageDead(_2);                 // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6
+-         drop(_1) -> bb9;                 // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         goto -> bb20;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+      }
+  
+      bb9: {
++         _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         _8 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         _9 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+          StorageDead(_1);                 // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+          return;                          // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2
+      }
+  
+      bb10 (cleanup): {
+          drop(_3) -> bb11;                // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20
+      }
+  
+      bb11 (cleanup): {
+-         drop(_1) -> bb12;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+      }
+  
+      bb12 (cleanup): {
+          resume;                          // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2
++     }
++ 
++     bb13 (cleanup): {
++         _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         goto -> bb12;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++     }
++ 
++     bb14: {
++         _7 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _8 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _9 = const true;                 // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         _1 = move _3;                    // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++         goto -> bb3;                     // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10
++     }
++ 
++     bb15: {
++         _7 = const false;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         goto -> bb9;                     // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb16 (cleanup): {
++         goto -> bb12;                    // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb17: {
++         drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb18 (cleanup): {
++         drop(_1) -> bb12;                // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb19: {
++         _10 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         switchInt(move _10) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb20: {
++         switchInt(_7) -> [0: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb21 (cleanup): {
++         _11 = discriminant(_1);          // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++         switchInt(move _11) -> [0: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
++     }
++ 
++     bb22 (cleanup): {
++         switchInt(_7) -> [0: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2
+      }
+  }
+  
diff --git a/tests/mir-opt/issue_41888.rs b/tests/mir-opt/issue_41888.rs
index c1046c14dbf..0f10c0a1d09 100644
--- a/tests/mir-opt/issue_41888.rs
+++ b/tests/mir-opt/issue_41888.rs
@@ -2,7 +2,7 @@
 // check that we clear the "ADT master drop flag" even when there are
 // no fields to be dropped.
 
-// EMIT_MIR issue_41888.main.ElaborateDrops.after.mir
+// EMIT_MIR issue_41888.main.ElaborateDrops.diff
 fn main() {
     let e;
     if cond() {