]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0594.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0594.md
1 A non-mutable value was assigned a value.
2
3 Erroneous code example:
4
5 ```compile_fail,E0594
6 struct SolarSystem {
7     earth: i32,
8 }
9
10 let ss = SolarSystem { earth: 3 };
11 ss.earth = 2; // error!
12 ```
13
14 To fix this error, declare `ss` as mutable by using the `mut` keyword:
15
16 ```
17 struct SolarSystem {
18     earth: i32,
19 }
20
21 let mut ss = SolarSystem { earth: 3 }; // declaring `ss` as mutable
22 ss.earth = 2; // ok!
23 ```