]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0384.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0384.md
1 An immutable variable was reassigned.
2
3 Erroneous code example:
4
5 ```compile_fail,E0384
6 fn main() {
7     let x = 3;
8     x = 5; // error, reassignment of immutable variable
9 }
10 ```
11
12 By default, variables in Rust are immutable. To fix this error, add the keyword
13 `mut` after the keyword `let` when declaring the variable. For example:
14
15 ```
16 fn main() {
17     let mut x = 3;
18     x = 5;
19 }
20 ```