Uh oh!
There was an error while loading. Please reload this page.
MIR-borrowck: Adding notes to E0506 - #44811
Conversation
rust-highfive
commented
Sep 24, 2017
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
GuillaumeGomez
commented
Sep 24, 2017
Could you please add a test for this change? Take a look at how they're done in |
zilbuz
commented
Sep 24, 2017
There is a test for E0506 (https://github.com/rust-lang/rust/blob/master/src/test/compile-fail/E0506.rs), but it doesn't test this message because the compiler uses the AST borrowck instead of the MIR borrowck. I manually checked that the messages were the same though. I assumed that the tests for MIR borrowck would be added on a later PR (@pnkfelix ?). Or maybe you're asking for a different kind of test ? |
We could actually use a UI test for this, but it's not feasible right now because we can't properly display lvalues in the MIR borrowck. |
pnkfelix
commented
Sep 25, 2017
In principle we could add a test, by telling the test infrastructure to pass the necessary In particular, you can do (I assume that the UI tests accept the same Whether its a good idea to put in tests for MIR-borrowck at this stage... it probably is worth it, just to make sure we don't regress. But maybe they should go into their own sub-directory or something, just to keep them isolated from "real tests" of current functionality. |
pnkfelix
commented
Sep 25, 2017
(After discussion in rust-impl-period/WG-compiler-nll, we decided that we will try the approach of extending the existing tests under |
bors
commented
Sep 26, 2017
☔ The latest upstream changes (presumably #44736) made this pull request unmergeable. Please resolve the merge conflicts. |
09f85ed to
b683538Comparezilbuz
commented
Sep 26, 2017
Alright I edited the tests on compile-fail that raise E0506. I omitted the tests that triggers ICE as other issues are supposed to fix them. |
arielb1
commented
Sep 27, 2017
Nice. I suppose we'll also want to add "borrow ends here" when we start supporting these, which should be soon. @bors r+ |
bors
commented
Sep 27, 2017
📌 Commit b683538 has been approved by |
| } | ||
| fn report_illegal_mutation_of_borrowed(&mut self, _: Context, (lvalue, span): (&Lvalue, Span)) { | ||
| fn report_illegal_mutation_of_borrowed(&mut self, |
There was a problem hiding this comment.
I think this should be moved to borrowck_errors actually, but that could be done in another commit.
There was a problem hiding this comment.
You mean like @mikhail-m1 has done in #44882 ?
| borrow2(x, x); | ||
| //~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable | ||
| //[ast]~^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable | ||
| //[mir]~^^ ERROR cannot borrow `*x` as immutable because it is also borrowed as mutable (Ast) |
There was a problem hiding this comment.
the ~^^ here could just be ~|
There was a problem hiding this comment.
No, it seems that when using revisions, the comments of the revision not currently compiled aren't processed. If I use ~|, I have the following error :compile-fail\coerce-overloaded-autoderef.rs' panicked at 'encountered //~| without preceding //~^ line.', src\libcore\option.rs:839:4
| borrow_mut2(x, x); | ||
| //~^ ERROR cannot borrow `*x` as mutable more than once at a time | ||
| //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time | ||
| //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) |
There was a problem hiding this comment.
the ~^^ here could just be ~|
| **x += 1; | ||
| //~^ ERROR cannot assign to `**x` because it is borrowed | ||
| //[ast]~^ ERROR cannot assign to `**x` because it is borrowed | ||
| //[mir]~^^ ERROR cannot assign to `**x` because it is borrowed (Ast) |
There was a problem hiding this comment.
the ~^^ here could just be ~|
| let z = borrow_mut(x); | ||
| //~^ ERROR cannot borrow `*x` as mutable more than once at a time | ||
| //[ast]~^ ERROR cannot borrow `*x` as mutable more than once at a time | ||
| //[mir]~^^ ERROR cannot borrow `*x` as mutable more than once at a time (Ast) |
There was a problem hiding this comment.
the ~^^ here could just be ~|
| v = MyVec { x: MyPtr { x: Foo { f: 23 } } }; | ||
| //~^ ERROR cannot assign to `v` | ||
| //[ast]~^ ERROR cannot assign to `v` | ||
| //[mir]~^^ ERROR cannot assign to `v` because it is borrowed (Ast) |
There was a problem hiding this comment.
the ~^^ here could just be ~|
bors
commented
Sep 29, 2017
MIR-borrowck: Adding notes to E0506 This PR adds notes to the MIR borrowck error E0506. Part of #44596
bors
commented
Sep 29, 2017
☀️ Test successful - status-appveyor, status-travis |
This PR adds notes to the MIR borrowck error E0506.
Part of #44596