summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/assign-non-lval-derefmut.stderr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/typeck/assign-non-lval-derefmut.stderr
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/typeck/assign-non-lval-derefmut.stderr')
-rw-r--r--src/test/ui/typeck/assign-non-lval-derefmut.stderr58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/test/ui/typeck/assign-non-lval-derefmut.stderr b/src/test/ui/typeck/assign-non-lval-derefmut.stderr
new file mode 100644
index 000000000..a6fcdfe21
--- /dev/null
+++ b/src/test/ui/typeck/assign-non-lval-derefmut.stderr
@@ -0,0 +1,58 @@
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/assign-non-lval-derefmut.rs:5:23
+ |
+LL | x.lock().unwrap() = 2;
+ | ----------------- ^
+ | |
+ | cannot assign to this expression
+ |
+help: consider dereferencing here to assign to the mutably borrowed value
+ |
+LL | *x.lock().unwrap() = 2;
+ | +
+
+error[E0368]: binary assignment operation `+=` cannot be applied to type `MutexGuard<'_, usize>`
+ --> $DIR/assign-non-lval-derefmut.rs:7:5
+ |
+LL | x.lock().unwrap() += 1;
+ | -----------------^^^^^
+ | |
+ | cannot use `+=` on type `MutexGuard<'_, usize>`
+ |
+help: `+=` can be used on `usize`, you can dereference `x.lock().unwrap()`
+ |
+LL | *x.lock().unwrap() += 1;
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/assign-non-lval-derefmut.rs:11:9
+ |
+LL | let mut y = x.lock().unwrap();
+ | ----------------- expected due to this value
+LL | y = 2;
+ | ^ expected struct `MutexGuard`, found integer
+ |
+ = note: expected struct `MutexGuard<'_, usize>`
+ found type `{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 `MutexGuard<'_, usize>`
+ --> $DIR/assign-non-lval-derefmut.rs:13:5
+ |
+LL | y += 1;
+ | -^^^^^
+ | |
+ | cannot use `+=` on type `MutexGuard<'_, 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`.