about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-06 19:58:07 +0000
committerbors <bors@rust-lang.org>2025-07-06 19:58:07 +0000
commita84ab0ce6c4557a2f01a3a6c3fdb0f92098db78d (patch)
tree6d4af5e6246009b37138160c05c8196af0c71b2b /compiler/rustc_mir_transform/src
parentde031bbcb161b0b7fc0eb16f77b02ce9fbdf4c9e (diff)
parentb1fdb4bdc8818aced53e46a34a3e92cfcfcc8ece (diff)
downloadrust-a84ab0ce6c4557a2f01a3a6c3fdb0f92098db78d.tar.gz
rust-a84ab0ce6c4557a2f01a3a6c3fdb0f92098db78d.zip
Auto merge of #143509 - cjgillot:copy-prop-noborrow, r=tmiasko
Do not unify borrowed locals in CopyProp.

Instead of trying yet another scheme to unify borrowed locals in CopyProp, let's just stop trying. We had already enough miscompilations because of this.

I'm convinced it's possible to have both unification of some borrowed locals and soundness, but I don't have a simple and convincing formulation yet.

Fixes https://github.com/rust-lang/rust/issues/143491
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/ssa.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs
index 03b6f9b7ff3..d3b4b99e932 100644
--- a/compiler/rustc_mir_transform/src/ssa.rs
+++ b/compiler/rustc_mir_transform/src/ssa.rs
@@ -322,8 +322,8 @@ fn compute_copy_classes(ssa: &mut SsaLocals, body: &Body<'_>) {
         // visited before `local`, and we just have to copy the representing local.
         let head = copies[rhs];
 
-        // Do not unify two borrowed locals.
-        if borrowed_classes.contains(local) && borrowed_classes.contains(head) {
+        // Do not unify borrowed locals.
+        if borrowed_classes.contains(local) || borrowed_classes.contains(head) {
             continue;
         }