You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've looked into this some - NLL misses three errors, all of the form cannot borrow `u.y` as immutable because `u.x` is also borrowed as mutable.
In each of the three cases, there is a mutable borrow of some field of the union and then a shared borrow of some other field immediately following. The issue seems to be that the mutable borrow is killed straight away as it isn't used later - therefore not causing a conflict with the shared borrow.
I'm inclined to think that this is fine - and that NLL is correct in having less errors here. However, we might want to update the test to use the first mutable borrow for each case in order to make the error happen and demonstrate the diagnostic - if this is the case, I've got a branch here that we can open a PR for that will update the test.
Activity
davidtwco commentedon Nov 4, 2018
I've looked into this some - NLL misses three errors, all of the form
cannot borrow `u.y` as immutable because `u.x` is also borrowed as mutable
.In each of the three cases, there is a mutable borrow of some field of the union and then a shared borrow of some other field immediately following. The issue seems to be that the mutable borrow is killed straight away as it isn't used later - therefore not causing a conflict with the shared borrow.
I'm inclined to think that this is fine - and that NLL is correct in having less errors here. However, we might want to update the test to use the first mutable borrow for each case in order to make the error happen and demonstrate the diagnostic - if this is the case, I've got a branch here that we can open a PR for that will update the test.
cc @nikomatsakis @pnkfelix
pnkfelix commentedon Nov 5, 2018
I'm inclined to agree that this is an instance where the test was not robust and that we need to add uses of those first mutable borrows.
davidtwco commentedon Nov 5, 2018
I've submitted a PR (#55696) that makes the test more robust.