Skip to content

Reason about borrowed classes in CopyProp. #142571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cjgillot
Copy link
Contributor

Fixes #141122

The current implementation of CopyProp avoids unifying two borrowed locals, as this would change the result of address comparison.

However, the implementation was inconsistent with the general algorithm, which identifies equivalence classes of locals and then replaces all locals by a single representative of their equivalence class.

This PR fixes it by forbidding the unification of two classes if any of those contain a borrowed local.

@rustbot
Copy link
Collaborator

rustbot commented Jun 16, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 16, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 16, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Jun 17, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 17, 2025

📌 Commit c4b67c6 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 17, 2025
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 18, 2025
Reason about borrowed classes in CopyProp.

Fixes rust-lang#141122

The current implementation of `CopyProp` avoids unifying two borrowed locals, as this would change the result of address comparison.

However, the implementation was inconsistent with the general algorithm, which identifies equivalence classes of locals and then replaces all locals by a single representative of their equivalence class.

This PR fixes it by forbidding the unification of two *classes* if any of those contain a borrowed local.
bors added a commit that referenced this pull request Jun 18, 2025
Rollup of 10 pull requests

Successful merges:

 - #135656 (Add `-Z hint-mostly-unused` to tell rustc that most of a crate will go unused)
 - #138237 (Get rid of `EscapeDebugInner`.)
 - #140772 ({aarch64,x86_64}-pc-windows-gnullvm: build host tools)
 - #140774 (Affirm `-Cforce-frame-pointers=off` does not override)
 - #141610 (Stabilize `feature(generic_arg_infer)`)
 - #141864 (Handle win32 separator for cygwin paths)
 - #142384 (Bringing `rustc_rayon_core` in tree as `rustc_thread_pool`)
 - #142502 (rustdoc_json: improve handling of generic args)
 - #142571 (Reason about borrowed classes in CopyProp.)
 - #142591 (Add spawn APIs for BootstrapCommand to support deferred command execution)

r? `@ghost`
`@rustbot` modify labels: rollup
@oli-obk oli-obk assigned oli-obk and unassigned SparrowLii Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CopyProp doesn't always respect Tree Borrows
5 participants