Skip to content

Commit 1bd28b1

Browse files
Clean up E0070 long explanation
1 parent ef35980 commit 1bd28b1

File tree

1 file changed

+20
-18
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+20
-18
lines changed

src/librustc_error_codes/error_codes/E0070.md

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
1-
The left-hand side of an assignment operator must be a place expression. A
2-
place expression represents a memory location and can be a variable (with
3-
optional namespacing), a dereference, an indexing expression or a field
4-
reference.
1+
An assignment operator was used on a non-place expression.
52

6-
More details can be found in the [Expressions] section of the Reference.
7-
8-
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries
9-
10-
Now, we can go further. Here are some erroneous code examples:
3+
Erroneous code examples:
114

125
```compile_fail,E0070
136
struct SomeStruct {
147
x: i32,
15-
y: i32
8+
y: i32,
169
}
1710
18-
const SOME_CONST : i32 = 12;
11+
const SOME_CONST: i32 = 12;
1912
2013
fn some_other_func() {}
2114
2215
fn some_function() {
23-
SOME_CONST = 14; // error : a constant value cannot be changed!
24-
1 = 3; // error : 1 isn't a valid place!
25-
some_other_func() = 4; // error : we cannot assign value to a function!
26-
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
27-
// like a variable!
16+
SOME_CONST = 14; // error: a constant value cannot be changed!
17+
1 = 3; // error: 1 isn't a valid place!
18+
some_other_func() = 4; // error: we cannot assign value to a function!
19+
SomeStruct::x = 12; // error: SomeStruct a structure name but it is used
20+
// like a variable!
2821
}
2922
```
3023

24+
The left-hand side of an assignment operator must be a place expression. A
25+
place expression represents a memory location and can be a variable (with
26+
optional namespacing), a dereference, an indexing expression or a field
27+
reference.
28+
29+
More details can be found in the [Expressions] section of the Reference.
30+
31+
[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries
32+
3133
And now let's give working examples:
3234

3335
```
3436
struct SomeStruct {
3537
x: i32,
36-
y: i32
38+
y: i32,
3739
}
38-
let mut s = SomeStruct {x: 0, y: 0};
40+
let mut s = SomeStruct { x: 0, y: 0 };
3941
4042
s.x = 3; // that's good !
4143

0 commit comments

Comments
 (0)