-
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
Issue #46589 - Kill borrows on a local variable whenever we assign ov… #46752
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
Issue #46589 (just to link it) Could you add a test? |
The code looks fine to me; just add a test and we should be good. |
I have added the test of issue #46589 and much to my surprise, it still fails, although it looks like it should be covered by my patch. I must be missing something obvious: error[E0506]: cannot assign to `list` because it is borrowed
--> /Users/david/Documents/Code/rust-nll/src/test/run-pass/nll-iterating-and-updating.rs:25:13
|
23 | result.push(&mut list.value);
| --------------- borrow of `list` occurs here
24 | if let Some(n) = list.next.as_mut() {
25 | list = n;
| ^^^^^^^^ assignment to borrowed `list` occurs here
error: aborting due to previous error |
Note: problem appears even if we add a let mut list = list; so it's probably not caused by |
I think that's because you haven't fixed this: rust/src/librustc_mir/borrow_check/mod.rs Lines 335 to 355 in a9f047c
|
Ok, thanks to @arielb1, this now seems to work. |
a96ad49
to
5e0e633
Compare
(oops, forgot to remove the obsolete test, this should now be fixed) |
@bors r+ |
📌 Commit 5e0e633 has been approved by |
⌛ Testing commit 5e0e633d1f780f865b4c8298f7116b274824994a with merge 627022b2338aeb9e7d416bb1c6fee34125d8ec32... |
💔 Test failed - status-appveyor |
As far as I can tell, the single failure is a timeout, which I imagine is not caused by this PR. |
@bors retry — 3 hour timeout.
|
Fwiw, |
☔ The latest upstream changes (presumably #46904) made this pull request unmergeable. Please resolve the merge conflicts. |
…assign over this variable
@bors r=arielb1 |
📌 Commit fcb1090 has been approved by |
Issue #46589 - Kill borrows on a local variable whenever we assign ov… …er this variable This is a first patch for the issue, handling the simple case while I figure out the data structures involved in the more complex cases.
☀️ Test successful - status-appveyor, status-travis |
…er this variable
This is a first patch for the issue, handling the simple case while I figure out the data structures involved in the more complex cases.