Skip to content

Commit

Permalink
extended info for E0595 closure cannot mutate immutable local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Jul 30, 2017
1 parent 5605d58 commit 7dab981
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/librustc_borrowck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,24 @@ fn main() {
```
"##,

E0595: r##"
Closures cannot mutate immutable captured variables.
Erroneous code example:
```compile_fail,E0595
let x = 3; // error: closure cannot assign to immutable local variable `x`
let mut c = || { x += 1 };
```
Make the variable binding mutable:
```
let mut x = 3; // ok!
let mut c = || { x += 1 };
```
"##,

E0596: r##"
This error occurs because you tried to mutably borrow a non-mutable variable.
Expand Down Expand Up @@ -1189,6 +1207,5 @@ register_diagnostics! {
// E0385, // {} in an aliasable location
E0524, // two closures require unique access to `..` at the same time
E0594, // cannot assign to {}
E0595, // closure cannot assign to {}
E0598, // lifetime of {} is too short to guarantee its contents can be...
}

0 comments on commit 7dab981

Please sign in to comment.