Skip to content

Commit f1e36ff

Browse files
Update diagnostics.rs
1 parent c0da2bd commit f1e36ff

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,33 @@ function's return type and the value being returned.
171171
"##,
172172

173173
E0070: r##"
174-
You tried to change the value of a const variable, which is not possible. Bad
175-
example:
174+
The left-hand side of an assignment operator must be an lvalue expression. An
175+
lvalue expression represents a memory location and includes item paths (ie,
176+
namespaced variables), dereferences, indexing expressions, and field references.
177+
178+
More details can be found here:
179+
https://doc.rust-lang.org/reference.html#lvalues,-rvalues-and-temporaries
176180
181+
Now, we can go further. Here are some bad examples:
177182
```
178183
const SOME_CONST : i32 = 12;
179184
180185
fn some_function() {
181186
SOME_CONST = 14; // error !
187+
1=3; // error
182188
}
183189
```
184190
185-
Constant variables' value cannot be changed once it has been set. Please take a
186-
look to static keyword if you want something similar but mutable:
191+
And now let's give good examples:
187192
188193
```
189194
static mut SOME_NOT_CONST : i32 = 12;
190195
191196
fn some_function() {
192197
SOME_NOT_CONST = 14; // that's good !
198+
let mut i : i32 = 1;
199+
200+
i = 3; // that's good !
193201
}
194202
```
195203
"##,

0 commit comments

Comments
 (0)