-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Kill conflicting borrows of places with projections. #62010
Conversation
Resolves rust-lang#62007. Due to a bug, the previous version of this check did not actually kill any conflicting borrows unless the borrowed place had no projections. Specifically, `entry_set` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program.
src/test/run-pass/borrowck/borrowck-borrow-of-projection-kills-other-borrows-issue-62007.rs
Outdated
Show resolved
Hide resolved
The test passed, so that's good. It would be good to add tests of each of the other kinds of projections, and check how they are handled. The test you've added here handles At the very least, I'd like to see:
It would of course be good to cover the other |
(the code changes here look good, too. I'll actually see about adding the tests I described so that we can get this into the pipeline to land sooner rather than later.) |
overwriting one field should not allow reborrow of an unrelated field.
I tried to make a variant of the tests I added above that covered the case of a downcast-projection, but I'm not sure if I know a way to get a downcast projection onto the righthand side of an assignment in the form that we need here to observe the phenomenon being tested. So I'm not going to worry about adding a test for that case at this point. (LIkewise, I'm not going to worry about subslice projection either.) |
r=me assuming the tests I added all pass the CI. |
@bors r+ |
📌 Commit f483269 has been approved by |
@bors rollup=never (This PR may affect performance. I don't think it will, so I'm not blocking it on a perf run. But I also want it to be apparent in the graphs if this PR does affect performance.) |
…, r=pnkfelix Kill conflicting borrows of places with projections. Resolves rust-lang#62007. Due to a bug, the previous version of this check did not actually kill all conflicting borrows unless the borrowed place had no projections. Specifically, `sets.on_entry` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program. @pnkfelix describes why this was not caught before in rust-lang#62007, and created an example where the current borrow checker failed unnecessarily. This PR adds their example as a test, but they will likely want to add some additional ones. r? @pnkfelix
…, r=pnkfelix Kill conflicting borrows of places with projections. Resolves rust-lang#62007. Due to a bug, the previous version of this check did not actually kill all conflicting borrows unless the borrowed place had no projections. Specifically, `sets.on_entry` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program. @pnkfelix describes why this was not caught before in rust-lang#62007, and created an example where the current borrow checker failed unnecessarily. This PR adds their example as a test, but they will likely want to add some additional ones. r? @pnkfelix
@Centril did I mistype the command for indicating this PR should not be included in a rollup? |
Kill conflicting borrows of places with projections. Resolves #62007. Due to a bug, the previous version of this check did not actually kill all conflicting borrows unless the borrowed place had no projections. Specifically, `sets.on_entry` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program. @pnkfelix describes why this was not caught before in #62007, and created an example where the current borrow checker failed unnecessarily. This PR adds their example as a test, but they will likely want to add some additional ones. r? @pnkfelix
@Centril Please file a feature request on rust-lang/homu |
☀️ Test successful - checks-travis, status-appveyor |
Resolves #62007.
Due to a bug, the previous version of this check did not actually kill all conflicting borrows unless the borrowed place had no projections. Specifically,
sets.on_entry
will always be empty whenstatement_effect
is called. It does not contain the set of borrows which are live at this point in the program.@pnkfelix describes why this was not caught before in #62007, and created an example where the current borrow checker failed unnecessarily. This PR adds their example as a test, but they will likely want to add some additional ones.
r? @pnkfelix