Skip to content

Commit 98e2917

Browse files
Clean up E0067 long explanation
1 parent 7e813c4 commit 98e2917

File tree

1 file changed

+7
-25
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+7
-25
lines changed
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
1-
The left-hand side of a compound assignment expression must be a place
2-
expression. A place expression represents a memory location and includes
3-
item paths (ie, namespaced variables), dereferences, indexing expressions,
4-
and field references.
1+
An invalid left-hand side expression was used on an assignment operation.
52

6-
Let's start with some erroneous code examples:
3+
Erroneous code example:
74

85
```compile_fail,E0067
9-
use std::collections::LinkedList;
10-
11-
// Bad: assignment to non-place expression
12-
LinkedList::new() += 1;
13-
14-
// ...
15-
16-
fn some_func(i: &mut i32) {
17-
i += 12; // Error : '+=' operation cannot be applied on a reference !
18-
}
6+
12 += 1; // error!
197
```
208

21-
And now some working examples:
9+
You need to have a place expression to be able to assign it something. For
10+
example:
2211

2312
```
24-
let mut i : i32 = 0;
25-
26-
i += 12; // Good !
27-
28-
// ...
29-
30-
fn some_func(i: &mut i32) {
31-
*i += 12; // Good !
32-
}
13+
let mut x: i8 = 12;
14+
x += 1; // ok!
3315
```

0 commit comments

Comments
 (0)