Skip to content

Commit db9b435

Browse files
Typo fix on E0067
1 parent c795406 commit db9b435

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,36 @@ and [RFC 809] for more details.
139139
"##,
140140

141141
E0067: r##"
142-
The left-hand side of an assignment operator must be an lvalue expression. An
143-
lvalue expression represents a memory location and includes item paths (ie,
144-
namespaced variables), dereferences, indexing expressions, and field
145-
references.
142+
The left-hand side of a compound assignment expression must be an lvalue
143+
expression. An lvalue expression represents a memory location and includes
144+
item paths (ie, namespaced variables), dereferences, indexing expressions,
145+
and field references.
146146
147+
Let's start with some bad examples:
147148
```
148149
use std::collections::LinkedList;
149150
150-
// Good
151-
let mut list = LinkedList::new();
152-
153-
154151
// Bad: assignment to non-lvalue expression
155152
LinkedList::new() += 1;
153+
154+
// ...
155+
156+
fn some_func(i: &mut i32) {
157+
i += 12; // Error : '+=' operation cannot be applied on a reference !
158+
}
159+
160+
And now some good examples:
161+
```
162+
let mut i : i32 = 0;
163+
164+
i += 12; // Good !
165+
166+
// ...
167+
168+
fn some_func(i: &mut i32) {
169+
*i += 12; // Good !
170+
}
171+
156172
```
157173
"##,
158174

0 commit comments

Comments
 (0)