about summary refs log tree commit diff
path: root/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr')
-rw-r--r--tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr216
1 files changed, 216 insertions, 0 deletions
diff --git a/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
new file mode 100644
index 00000000000..1b93267b397
--- /dev/null
+++ b/tests/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.stderr
@@ -0,0 +1,216 @@
+error[E0505]: cannot move out of `arr[..]` because it is borrowed
+  --> $DIR/borrowck-move-ref-pattern.rs:8:24
+   |
+LL |     let hold_all = &arr;
+   |                    ---- borrow of `arr` occurs here
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |                        ^^^ move out of `arr[..]` occurs here
+LL |     _x1 = U;
+LL |     drop(hold_all);
+   |          -------- borrow later used here
+
+error[E0384]: cannot assign twice to immutable variable `_x1`
+  --> $DIR/borrowck-move-ref-pattern.rs:9:5
+   |
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |                        ---
+   |                        |
+   |                        first assignment to `_x1`
+   |                        help: consider making this binding mutable: `mut _x1`
+LL |     _x1 = U;
+   |     ^^^^^^^ cannot assign twice to immutable variable
+
+error[E0505]: cannot move out of `arr[..]` because it is borrowed
+  --> $DIR/borrowck-move-ref-pattern.rs:11:10
+   |
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |          ------------ borrow of `arr[..]` occurs here
+...
+LL |     let [_x0, ..] = arr;
+   |          ^^^ move out of `arr[..]` occurs here
+LL |     drop(_x0_hold);
+   |          -------- borrow later used here
+
+error[E0502]: cannot borrow `arr[..]` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-move-ref-pattern.rs:13:16
+   |
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |                             ----------- immutable borrow occurs here
+...
+LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
+   |                ^^^^^^^^^^^ mutable borrow occurs here
+...
+LL |     drop(xs_hold);
+   |          ------- immutable borrow later used here
+
+error[E0505]: cannot move out of `arr[..]` because it is borrowed
+  --> $DIR/borrowck-move-ref-pattern.rs:13:29
+   |
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |                             ----------- borrow of `arr[..]` occurs here
+...
+LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
+   |                             ^^^ move out of `arr[..]` occurs here
+...
+LL |     drop(xs_hold);
+   |          ------- borrow later used here
+
+error[E0505]: cannot move out of `arr[..]` because it is borrowed
+  --> $DIR/borrowck-move-ref-pattern.rs:13:34
+   |
+LL |     let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
+   |                             ----------- borrow of `arr[..]` occurs here
+...
+LL |     let [_, _, ref mut _x2, _x3, mut _x4] = arr;
+   |                                  ^^^^^^^ move out of `arr[..]` occurs here
+...
+LL |     drop(xs_hold);
+   |          ------- borrow later used here
+
+error[E0384]: cannot assign twice to immutable variable `_x1`
+  --> $DIR/borrowck-move-ref-pattern.rs:23:5
+   |
+LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
+   |                   ---
+   |                   |
+   |                   first assignment to `_x1`
+   |                   help: consider making this binding mutable: `mut _x1`
+LL |     _x1 = U;
+   |     ^^^^^^^ cannot assign twice to immutable variable
+
+error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-move-ref-pattern.rs:24:20
+   |
+LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
+   |          ------- immutable borrow occurs here
+LL |     _x1 = U;
+LL |     let _x0_hold = &mut tup.0;
+   |                    ^^^^^^^^^^ mutable borrow occurs here
+LL |     let (ref mut _x0_hold, ..) = tup;
+LL |     *_x0 = U;
+   |     -------- immutable borrow later used here
+
+error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
+  --> $DIR/borrowck-move-ref-pattern.rs:25:10
+   |
+LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
+   |          ------- immutable borrow occurs here
+...
+LL |     let (ref mut _x0_hold, ..) = tup;
+   |          ^^^^^^^^^^^^^^^^ mutable borrow occurs here
+LL |     *_x0 = U;
+   |     -------- immutable borrow later used here
+
+error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
+  --> $DIR/borrowck-move-ref-pattern.rs:26:5
+   |
+LL |     *_x0 = U;
+   |     ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let (ref mut _x0, _x1, ref _x2, ..) = tup;
+   |          ~~~~~~~~~~~
+
+error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
+  --> $DIR/borrowck-move-ref-pattern.rs:27:5
+   |
+LL |     *_x2 = U;
+   |     ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written
+   |
+help: consider changing this to be a mutable reference
+   |
+LL |     let (ref _x0, _x1, ref mut _x2, ..) = tup;
+   |                        ~~~~~~~~~~~
+
+error[E0382]: use of moved value: `tup.1`
+  --> $DIR/borrowck-move-ref-pattern.rs:28:10
+   |
+LL |     let (ref _x0, _x1, ref _x2, ..) = tup;
+   |                   --- value moved here
+...
+LL |     drop(tup.1);
+   |          ^^^^^ value used here after move
+   |
+   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
+help: borrow this binding in the pattern to avoid moving the value
+   |
+LL |     let (ref _x0, ref _x1, ref _x2, ..) = tup;
+   |                   +++
+
+error[E0382]: borrow of moved value: `tup.1`
+  --> $DIR/borrowck-move-ref-pattern.rs:29:20
+   |
+LL |     drop(tup.1);
+   |          ----- value moved here
+LL |     let _x1_hold = &tup.1;
+   |                    ^^^^^^ value borrowed here after move
+   |
+   = note: move occurs because `tup.1` has type `U`, which does not implement the `Copy` trait
+
+error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
+  --> $DIR/borrowck-move-ref-pattern.rs:31:20
+   |
+LL |     let (.., ref mut _x3) = tup;
+   |              ----------- mutable borrow occurs here
+LL |     let _x3_hold = &tup.3;
+   |                    ^^^^^^ immutable borrow occurs here
+...
+LL |     drop(_x3);
+   |          --- mutable borrow later used here
+
+error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
+  --> $DIR/borrowck-move-ref-pattern.rs:32:20
+   |
+LL |     let (.., ref mut _x3) = tup;
+   |              ----------- first mutable borrow occurs here
+LL |     let _x3_hold = &tup.3;
+LL |     let _x3_hold = &mut tup.3;
+   |                    ^^^^^^^^^^ second mutable borrow occurs here
+...
+LL |     drop(_x3);
+   |          --- first borrow later used here
+
+error[E0499]: cannot borrow `tup.3` as mutable more than once at a time
+  --> $DIR/borrowck-move-ref-pattern.rs:33:14
+   |
+LL |     let (.., ref mut _x3) = tup;
+   |              ----------- first mutable borrow occurs here
+...
+LL |     let (.., ref mut _x4_hold) = tup;
+   |              ^^^^^^^^^^^^^^^^ second mutable borrow occurs here
+LL |     let (.., ref _x4_hold) = tup;
+LL |     drop(_x3);
+   |          --- first borrow later used here
+
+error[E0502]: cannot borrow `tup.3` as immutable because it is also borrowed as mutable
+  --> $DIR/borrowck-move-ref-pattern.rs:34:14
+   |
+LL |     let (.., ref mut _x3) = tup;
+   |              ----------- mutable borrow occurs here
+...
+LL |     let (.., ref _x4_hold) = tup;
+   |              ^^^^^^^^^^^^ immutable borrow occurs here
+LL |     drop(_x3);
+   |          --- mutable borrow later used here
+
+error[E0382]: use of moved value: `tup`
+  --> $DIR/borrowck-move-ref-pattern.rs:43:14
+   |
+LL |     let mut tup = (U, U, U);
+   |         ------- move occurs because `tup` has type `(U, U, U)`, which does not implement the `Copy` trait
+LL |     let c1 = || {
+   |              -- value moved into closure here
+LL |         let (ref _x0, _x1, _) = tup;
+   |                                 --- variable moved due to use in closure
+LL |     };
+LL |     let c2 = || {
+   |              ^^ value used here after move
+LL |
+LL |         let (ref mut _x0, _, _x2) = tup;
+   |                                     --- use occurs due to use in closure
+
+error: aborting due to 18 previous errors
+
+Some errors have detailed explanations: E0382, E0384, E0499, E0502, E0505, E0594.
+For more information about an error, try `rustc --explain E0382`.