summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr')
-rw-r--r--tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr
new file mode 100644
index 000000000..ce9f7aa05
--- /dev/null
+++ b/tests/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.stderr
@@ -0,0 +1,34 @@
+error[E0594]: cannot assign to `**t1`, which is behind a `&` reference
+ --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:9:5
+ |
+LL | let t1 = t0;
+ | -- consider changing this binding's type to be: `&mut &mut isize`
+LL | let p: &isize = &**t0;
+LL | **t1 = 22;
+ | ^^^^^^^^^ `t1` is a `&` reference, so the data it refers to cannot be written
+
+error[E0502]: cannot borrow `**t0` as immutable because it is also borrowed as mutable
+ --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:14:21
+ |
+LL | let t1 = &mut *t0;
+ | -------- mutable borrow occurs here
+LL | let p: &isize = &**t0;
+ | ^^^^^ immutable borrow occurs here
+LL | **t1 = 22;
+ | --------- mutable borrow later used here
+
+error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference
+ --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:19:26
+ |
+LL | let x: &mut isize = &mut **t0;
+ | ^^^^^^^^^ `t0` is a `&` reference, so the data it refers to cannot be borrowed as mutable
+ |
+help: consider changing this to be a mutable reference
+ |
+LL | fn foo4(t0: &mut &mut isize) {
+ | ~~~~~~~~~~~~~~~
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0502, E0594, E0596.
+For more information about an error, try `rustc --explain E0502`.