Skip to content

Commit 7c7e42a

Browse files
Add error explanation for E0070
1 parent 2dd5ad0 commit 7c7e42a

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ be specified exactly one time.
124124

125125
E0063: r##"
126126
This error indicates that during an attempt to build a struct or struct-like
127-
enum variant, one of the fields was not provided. Each field should be specified
128-
exactly once.
127+
enum variant, one of the fields was not provided. Each field should be
128+
specified exactly once.
129129
"##,
130130

131131
E0066: r##"
@@ -141,7 +141,8 @@ and [RFC 809] for more details.
141141
E0067: r##"
142142
The left-hand side of an assignment operator must be an lvalue expression. An
143143
lvalue expression represents a memory location and includes item paths (ie,
144-
namespaced variables), dereferences, indexing expressions, and field references.
144+
namespaced variables), dereferences, indexing expressions, and field
145+
references.
145146
146147
```
147148
use std::collections::LinkedList;
@@ -170,6 +171,37 @@ Since `return;` is just like `return ();`, there is a mismatch between the
170171
function's return type and the value being returned.
171172
"##,
172173

174+
E0070: r##"
175+
The left-hand side of an assignment operator must be an lvalue expression. An
176+
lvalue expression represents a memory location and can be a variable (with
177+
optional namespacing), a dereference, an indexing expression or a field
178+
reference.
179+
180+
More details can be found here:
181+
https://doc.rust-lang.org/reference.html#lvalues,-rvalues-and-temporaries
182+
183+
Now, we can go further. Here are some bad examples:
184+
```
185+
const SOME_CONST : i32 = 12;
186+
187+
fn some_other_func() {}
188+
189+
fn some_function() {
190+
SOME_CONST = 14; // error : a constant value cannot be changed!
191+
1 = 3; // error : 1 isn't a valid lvalue!
192+
some_other_func() = 4; // error : we can't assign value to a function!
193+
}
194+
```
195+
196+
And now let's give good examples:
197+
198+
```
199+
let mut i : i32 = 1; // that's good
200+
201+
i = 3; // that's good !
202+
```
203+
"##,
204+
173205
E0072: r##"
174206
When defining a recursive struct or enum, any use of the type being defined
175207
from inside the definition must occur behind a pointer (like `Box` or `&`).
@@ -779,7 +811,6 @@ register_diagnostics! {
779811
E0060,
780812
E0061,
781813
E0068,
782-
E0070,
783814
E0071,
784815
E0074,
785816
E0075,

0 commit comments

Comments
 (0)