diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2017-07-27 21:42:03 -0700 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2017-07-30 11:10:35 -0700 |
| commit | 7dab9812c4f76aac6e442ff053c34c076b76643d (patch) | |
| tree | 75ef68a20f953913a5fa861d1c2f863def6c3fd3 | |
| parent | 5605d58fc79e1cdacfbf01266a2d46b76df53ede (diff) | |
| download | rust-7dab9812c4f76aac6e442ff053c34c076b76643d.tar.gz rust-7dab9812c4f76aac6e442ff053c34c076b76643d.zip | |
extended info for E0595 closure cannot mutate immutable local variable
| -rw-r--r-- | src/librustc_borrowck/diagnostics.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs index 38dcc731236..fea9d0d6f13 100644 --- a/src/librustc_borrowck/diagnostics.rs +++ b/src/librustc_borrowck/diagnostics.rs @@ -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. @@ -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... } |
