Skip to content

Commit 74787b9

Browse files
Added error explanation for E0384.
1 parent 832e5a0 commit 74787b9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/librustc_borrowck/diagnostics.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,35 @@ fn main() {
7373
7474
To fix this, ensure that any declared variables are initialized before being
7575
used.
76+
"##,
77+
78+
E0384: r##"
79+
This error occurs when an attempt is made to reassign an immutable variable.
80+
For example:
81+
82+
```
83+
fn main(){
84+
let x = 3;
85+
x = 5; // error, reassignment of immutable variable
86+
}
87+
```
88+
89+
By default, variables in Rust are immutable. To fix this error, add the keyword
90+
`mut` after the keyword `let` when declaring the variable. For example:
91+
92+
```
93+
fn main(){
94+
let mut x = 3;
95+
x = 5;
96+
}
97+
```
7698
"##
7799

78100
}
79101

80102
register_diagnostics! {
81103
E0382, // use of partially/collaterally moved value
82104
E0383, // partial reinitialization of uninitialized structure
83-
E0384, // reassignment of immutable variable
84105
E0385, // {} in an aliasable location
85106
E0386, // {} in an immutable container
86107
E0387, // {} in a captured outer variable in an `Fn` closure

0 commit comments

Comments
 (0)