]> git.lizzy.rs Git - rust.git/blob - src/test/ui/typeck/assign-non-lval-derefmut.stderr
:arrow_up: rust-analyzer
[rust.git] / src / test / ui / typeck / assign-non-lval-derefmut.stderr
1 error[E0070]: invalid left-hand side of assignment
2   --> $DIR/assign-non-lval-derefmut.rs:5:23
3    |
4 LL |     x.lock().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.lock().unwrap() = 2;
12    |     +
13
14 error[E0368]: binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
15   --> $DIR/assign-non-lval-derefmut.rs:7:5
16    |
17 LL |     x.lock().unwrap() += 1;
18    |     -----------------^^^^^
19    |     |
20    |     cannot use `+=` on type `MutexGuard<'_, usize>`
21    |
22 help: `+=` can be used on `usize`, you can dereference `x.lock().unwrap()`
23    |
24 LL |     *x.lock().unwrap() += 1;
25    |     +
26
27 error[E0308]: mismatched types
28   --> $DIR/assign-non-lval-derefmut.rs:11:9
29    |
30 LL |     let mut y = x.lock().unwrap();
31    |                 ----------------- expected due to this value
32 LL |     y = 2;
33    |         ^ expected struct `MutexGuard`, found integer
34    |
35    = note: expected struct `MutexGuard<'_, usize>`
36                 found type `{integer}`
37 help: consider dereferencing here to assign to the mutably borrowed value
38    |
39 LL |     *y = 2;
40    |     +
41
42 error[E0368]: binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
43   --> $DIR/assign-non-lval-derefmut.rs:13:5
44    |
45 LL |     y += 1;
46    |     -^^^^^
47    |     |
48    |     cannot use `+=` on type `MutexGuard<'_, usize>`
49    |
50 help: `+=` can be used on `usize`, you can dereference `y`
51    |
52 LL |     *y += 1;
53    |     +
54
55 error: aborting due to 4 previous errors
56
57 Some errors have detailed explanations: E0070, E0308, E0368.
58 For more information about an error, try `rustc --explain E0070`.