summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/assign-non-lval-mut-ref.stderr
blob: be2e9fe95e87144a3e27ffcfe1d4d14267c2d14e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
error[E0070]: invalid left-hand side of assignment
  --> $DIR/assign-non-lval-mut-ref.rs:5:27
   |
LL |     x.last_mut().unwrap() = 2;
   |     --------------------- ^
   |     |
   |     cannot assign to this expression
   |
help: consider dereferencing here to assign to the mutably borrowed value
   |
LL |     *x.last_mut().unwrap() = 2;
   |     +

error[E0368]: binary assignment operation `+=` cannot be applied to type `&mut usize`
  --> $DIR/assign-non-lval-mut-ref.rs:7:5
   |
LL |     x.last_mut().unwrap() += 1;
   |     ---------------------^^^^^
   |     |
   |     cannot use `+=` on type `&mut usize`
   |
help: `+=` can be used on `usize`, you can dereference `x.last_mut().unwrap()`
   |
LL |     *x.last_mut().unwrap() += 1;
   |     +

error[E0308]: mismatched types
  --> $DIR/assign-non-lval-mut-ref.rs:11:9
   |
LL |     let y = x.last_mut().unwrap();
   |             --------------------- expected due to this value
LL |     y = 2;
   |         ^ expected `&mut usize`, found integer
   |
help: consider dereferencing here to assign to the mutably borrowed value
   |
LL |     *y = 2;
   |     +

error[E0368]: binary assignment operation `+=` cannot be applied to type `&mut usize`
  --> $DIR/assign-non-lval-mut-ref.rs:13:5
   |
LL |     y += 1;
   |     -^^^^^
   |     |
   |     cannot use `+=` on type `&mut usize`
   |
help: `+=` can be used on `usize`, you can dereference `y`
   |
LL |     *y += 1;
   |     +

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0070, E0308, E0368.
For more information about an error, try `rustc --explain E0070`.