]>
Commit | Line | Data |
---|---|---|
923072b8 FG |
1 | error[E0070]: invalid left-hand side of assignment |
2 | --> $DIR/assign-non-lval-mut-ref.rs:5:27 | |
3 | | | |
4 | LL | x.last_mut().unwrap() = 2; | |
5 | | --------------------- ^ | |
6 | | | | |
7 | | cannot assign to this expression | |
8 | | | |
9 | help: consider dereferencing here to assign to the mutably borrowed value | |
10 | | | |
11 | LL | *x.last_mut().unwrap() = 2; | |
12 | | + | |
13 | ||
14 | error[E0368]: binary assignment operation `+=` cannot be applied to type `&mut usize` | |
15 | --> $DIR/assign-non-lval-mut-ref.rs:7:5 | |
16 | | | |
17 | LL | x.last_mut().unwrap() += 1; | |
18 | | ---------------------^^^^^ | |
19 | | | | |
20 | | cannot use `+=` on type `&mut usize` | |
21 | | | |
f2b60f7d | 22 | help: `+=` can be used on `usize` if you dereference the left-hand side |
923072b8 FG |
23 | | |
24 | LL | *x.last_mut().unwrap() += 1; | |
25 | | + | |
26 | ||
27 | error[E0308]: mismatched types | |
28 | --> $DIR/assign-non-lval-mut-ref.rs:11:9 | |
29 | | | |
30 | LL | let y = x.last_mut().unwrap(); | |
31 | | --------------------- expected due to this value | |
32 | LL | y = 2; | |
33 | | ^ expected `&mut usize`, found integer | |
34 | | | |
35 | help: consider dereferencing here to assign to the mutably borrowed value | |
36 | | | |
37 | LL | *y = 2; | |
38 | | + | |
39 | ||
40 | error[E0368]: binary assignment operation `+=` cannot be applied to type `&mut usize` | |
41 | --> $DIR/assign-non-lval-mut-ref.rs:13:5 | |
42 | | | |
43 | LL | y += 1; | |
44 | | -^^^^^ | |
45 | | | | |
46 | | cannot use `+=` on type `&mut usize` | |
47 | | | |
f2b60f7d | 48 | help: `+=` can be used on `usize` if you dereference the left-hand side |
923072b8 FG |
49 | | |
50 | LL | *y += 1; | |
51 | | + | |
52 | ||
53 | error: aborting due to 4 previous errors | |
54 | ||
55 | Some errors have detailed explanations: E0070, E0308, E0368. | |
56 | For more information about an error, try `rustc --explain E0070`. |