2020-01-18 19:47:01 -06:00
|
|
|
error[E0505]: cannot move out of `arr[..]` because it is borrowed
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:8:24
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
2023-01-14 21:06:44 -06:00
|
|
|
LL | let mut arr = [U, U, U, U, U];
|
|
|
|
| ------- binding `arr` declared here
|
2020-01-18 19:47:01 -06:00
|
|
|
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`
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:9:5
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
|
|
|
|
| ---
|
|
|
|
| |
|
|
|
|
| first assignment to `_x1`
|
2021-04-12 17:29:09 -05:00
|
|
|
| help: consider making this binding mutable: `mut _x1`
|
2020-01-18 19:47:01 -06:00
|
|
|
LL | _x1 = U;
|
|
|
|
| ^^^^^^^ cannot assign twice to immutable variable
|
|
|
|
|
|
|
|
error[E0505]: cannot move out of `arr[..]` because it is borrowed
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:11:10
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:13:16
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
|
2022-09-03 17:55:53 -05:00
|
|
|
| ----------- immutable borrow occurs here
|
2020-01-18 19:47:01 -06:00
|
|
|
...
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:13:29
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
|
2022-09-03 17:55:53 -05:00
|
|
|
| ----------- borrow of `arr[..]` occurs here
|
2020-01-18 19:47:01 -06:00
|
|
|
...
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:13:34
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | let [ref _x0_hold, _x1, ref xs_hold @ ..] = arr;
|
2022-09-03 17:55:53 -05:00
|
|
|
| ----------- borrow of `arr[..]` occurs here
|
2020-01-18 19:47:01 -06:00
|
|
|
...
|
|
|
|
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`
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:23:5
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | let (ref _x0, _x1, ref _x2, ..) = tup;
|
|
|
|
| ---
|
|
|
|
| |
|
|
|
|
| first assignment to `_x1`
|
2021-04-12 17:29:09 -05:00
|
|
|
| help: consider making this binding mutable: `mut _x1`
|
2020-01-18 19:47:01 -06:00
|
|
|
LL | _x1 = U;
|
|
|
|
| ^^^^^^^ cannot assign twice to immutable variable
|
|
|
|
|
|
|
|
error[E0502]: cannot borrow `tup.0` as mutable because it is also borrowed as immutable
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:24:20
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:25:10
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-07-02 11:29:49 -05:00
|
|
|
error[E0594]: cannot assign to `*_x0`, which is behind a `&` reference
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:26:5
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | *_x0 = U;
|
|
|
|
| ^^^^^^^^ `_x0` is a `&` reference, so the data it refers to cannot be written
|
2022-12-28 23:52:57 -06:00
|
|
|
|
|
|
|
|
help: consider changing this to be a mutable reference
|
|
|
|
|
|
|
|
|
LL | let (ref mut _x0, _x1, ref _x2, ..) = tup;
|
2023-04-20 01:58:43 -05:00
|
|
|
| +++
|
2020-01-18 19:47:01 -06:00
|
|
|
|
2021-07-02 11:29:49 -05:00
|
|
|
error[E0594]: cannot assign to `*_x2`, which is behind a `&` reference
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:27:5
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
LL | *_x2 = U;
|
|
|
|
| ^^^^^^^^ `_x2` is a `&` reference, so the data it refers to cannot be written
|
2022-12-28 23:52:57 -06:00
|
|
|
|
|
|
|
|
help: consider changing this to be a mutable reference
|
|
|
|
|
|
|
|
|
LL | let (ref _x0, _x1, ref mut _x2, ..) = tup;
|
2023-04-20 01:58:43 -05:00
|
|
|
| +++
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
error[E0382]: use of moved value: `tup.1`
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:28:10
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2022-11-02 23:22:24 -05:00
|
|
|
help: borrow this binding in the pattern to avoid moving the value
|
|
|
|
|
|
|
|
|
LL | let (ref _x0, ref _x1, ref _x2, ..) = tup;
|
|
|
|
| +++
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
error[E0382]: borrow of moved value: `tup.1`
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:29:20
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:31:20
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:32:20
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:33:14
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:34:14
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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`
|
2020-08-30 13:59:56 -05:00
|
|
|
--> $DIR/borrowck-move-ref-pattern.rs:43:14
|
2020-01-18 19:47:01 -06:00
|
|
|
|
|
|
|
|
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`.
|