Slightly incorrect error on mutable borrow of immutable captured variable #18330
Closed
Description
Code:
fn set(x: &mut usize) { *x = 1; }
fn main() {
let x = 0;
|| set(&mut x);
}
Output:
<anon>:7:5: 7:19 error: closure cannot assign to immutable local variable `x`
<anon>:7 || set(&mut x);
^~~~~~~~~~~~~~
This should actually state that it cannot borrow (rather than assign) the variable. This has been around since 0.10 at least.
Activity