]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0067.md
Rollup merge of #66411 - RalfJung:forget, r=sfackler
[rust.git] / src / librustc_error_codes / error_codes / E0067.md
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.
5
6 Let's start with some erroneous code examples:
7
8 ```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 }
19 ```
20
21 And now some working examples:
22
23 ```
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 }
33 ```