]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_mir_transform/src/dest_prop.rs
Rollup merge of #105570 - Nilstrieb:actual-best-failure, r=compiler-errors
[rust.git] / compiler / rustc_mir_transform / src / dest_prop.rs
index 3e45319431cec0e9de6816ed78310c892d09d461..08e296a837127b72911b152275b7c242ca47d0f9 100644 (file)
 
 use std::collections::hash_map::{Entry, OccupiedEntry};
 
+use crate::simplify::remove_dead_blocks;
 use crate::MirPass;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_index::bit_set::BitSet;
@@ -235,6 +236,12 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
             apply_merges(body, tcx, &merges, &merged_locals);
         }
 
+        if round_count != 0 {
+            // Merging can introduce overlap between moved arguments and/or call destination in an
+            // unreachable code, which validator considers to be ill-formed.
+            remove_dead_blocks(tcx, body);
+        }
+
         trace!(round_count);
     }
 }
@@ -651,7 +658,7 @@ fn for_terminator<'tcx>(&mut self, terminator: &TerminatorKind<'tcx>) {
         }
     }
 
-    fn add_place<'tcx>(&mut self, place: Place<'tcx>) {
+    fn add_place(&mut self, place: Place<'_>) {
         self.writes.push(place.local);
     }