@@ -124,8 +124,8 @@ be specified exactly one time.
124
124
125
125
E0063 : r##"
126
126
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.
129
129
"## ,
130
130
131
131
E0066 : r##"
@@ -141,7 +141,8 @@ and [RFC 809] for more details.
141
141
E0067 : r##"
142
142
The left-hand side of an assignment operator must be an lvalue expression. An
143
143
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.
145
146
146
147
```
147
148
use std::collections::LinkedList;
@@ -170,6 +171,53 @@ Since `return;` is just like `return ();`, there is a mismatch between the
170
171
function's return type and the value being returned.
171
172
"## ,
172
173
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
+ struct SomeStruct {
186
+ x: i32,
187
+ y: i32
188
+ }
189
+ const SOME_CONST : i32 = 12;
190
+
191
+ fn some_other_func() {}
192
+
193
+ fn some_function() {
194
+ SOME_CONST = 14; // error : a constant value cannot be changed!
195
+ 1 = 3; // error : 1 isn't a valid lvalue!
196
+ some_other_func() = 4; // error : we can't assign value to a function!
197
+ SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
198
+ // like a variable!
199
+ }
200
+ ```
201
+
202
+ And now let's give good examples:
203
+
204
+ ```
205
+ struct SomeStruct {
206
+ x: i32,
207
+ y: i32
208
+ }
209
+ let mut s = SomeStruct {x: 0, y: 0};
210
+
211
+ s.x = 3; // that's good !
212
+
213
+ // ...
214
+
215
+ fn some_func(x: &mut i32) {
216
+ *x = 12; // that's good !
217
+ }
218
+ ```
219
+ "## ,
220
+
173
221
E0072 : r##"
174
222
When defining a recursive struct or enum, any use of the type being defined
175
223
from inside the definition must occur behind a pointer (like `Box` or `&`).
@@ -779,7 +827,6 @@ register_diagnostics! {
779
827
E0060 ,
780
828
E0061 ,
781
829
E0068 ,
782
- E0070 ,
783
830
E0071 ,
784
831
E0074 ,
785
832
E0075 ,
0 commit comments