Skip to content

Commit e533190

Browse files
Add error explanation for E0070
1 parent 8b7c17d commit e533190

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ Since `return;` is just like `return ();`, there is a mismatch between the
170170
function's return type and the value being returned.
171171
"##,
172172

173+
E0070: r##"
174+
You tried to change the value of a const variable, which is not possible. Bad
175+
example:
176+
177+
```
178+
const SOME_CONST : i32 = 12;
179+
180+
fn some_function() {
181+
SOME_CONST = 14; // error !
182+
}
183+
```
184+
185+
Constant variables' value can be changed once it has been set. Please take a
186+
look to static keyword if you want something similar but mutable:
187+
188+
```
189+
static mut SOME_NOT_CONST : i32 = 12;
190+
191+
fn some_function() {
192+
SOME_NOT_CONST = 14; // that's good !
193+
}
194+
```
195+
"##,
196+
173197
E0081: r##"
174198
Enum discriminants are used to differentiate enum variants stored in memory.
175199
This error indicates that the same value was used for two or more variants,
@@ -658,7 +682,6 @@ register_diagnostics! {
658682
E0060,
659683
E0061,
660684
E0068,
661-
E0070,
662685
E0071,
663686
E0072,
664687
E0073,

0 commit comments

Comments
 (0)