Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMisleading error message when borrowing immutably in closure #32577
Comments
This comment has been minimized.
This comment has been minimized.
|
Hello. Can you please provide a more lightweight example to this? If not, then what do you think the description should look like? Since it's somewhat confusing to a beginner like me, I'm having a hard time understanding what's exactly going on here. |
This comment has been minimized.
This comment has been minimized.
|
I guess the "borrow occurs" note should be replaced by something like "unique access required because of mutable access to |
This comment has been minimized.
This comment has been minimized.
|
@cengizIO don't think this example can be reduced. The issue is with
This part of the diagnosis is wrong - It might also help to talk about unique access and mutable borrows, but I'm less concerned about that. |
apasel422
added
the
A-diagnostics
label
Jun 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Even smaller example: fn main() {
let mut a = ();
let borrow = &a;
(|| {
&a;
&mut a;
})();
}
|
aidanhs commentedMar 29, 2016
•
edited by apasel422
http://is.gd/NKVuFN
Error message:
(this error message is repeated three times, even when I compile locally, but that's a distraction)
All you need to do is comment out the
self.b += 1;line to make it compile - talking aboutself.ais misleading because it's not a mutable borrow and is therefore fine.