about summary refs log tree commit diff
path: root/src/librustc_error_codes/error_codes
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-11-19 13:10:12 +0100
committerGitHub <noreply@github.com>2019-11-19 13:10:12 +0100
commit40deec82bcb9f13829f60a30d1bc3afedb9d5c8c (patch)
treefada756da967ae655bd06e5ccbd9d13e1fca436a /src/librustc_error_codes/error_codes
parent49077c59a81cb1361bb41a8197cf5499d54677f0 (diff)
parentc981c994d44801df0a68566467b0bf059f714c3d (diff)
downloadrust-40deec82bcb9f13829f60a30d1bc3afedb9d5c8c.tar.gz
rust-40deec82bcb9f13829f60a30d1bc3afedb9d5c8c.zip
Rollup merge of #66155 - GuillaumeGomez:long-err-explanation-E0594, r=Dylan-DPC
Add long error explanation for E0594

Part of #61137.

r? @Dylan-DPC
Diffstat (limited to 'src/librustc_error_codes/error_codes')
-rw-r--r--src/librustc_error_codes/error_codes/E0594.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/librustc_error_codes/error_codes/E0594.md b/src/librustc_error_codes/error_codes/E0594.md
new file mode 100644
index 00000000000..ad8eb631e63
--- /dev/null
+++ b/src/librustc_error_codes/error_codes/E0594.md
@@ -0,0 +1,23 @@
+A non-mutable value was assigned a value.
+
+Erroneous code example:
+
+```compile_fail,E0594
+struct SolarSystem {
+    earth: i32,
+}
+
+let ss = SolarSystem { earth: 3 };
+ss.earth = 2; // error!
+```
+
+To fix this error, declare `ss` as mutable by using the `mut` keyword:
+
+```
+struct SolarSystem {
+    earth: i32,
+}
+
+let mut ss = SolarSystem { earth: 3 }; // declaring `ss` as mutable
+ss.earth = 2; // ok!
+```