1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-closures-slice-patterns.rs:7:13
|
LL | let f = || {
| -- immutable borrow occurs here
LL | let [ref y, ref z @ ..] = x;
| - first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &mut x;
| ^^^^^^ mutable borrow occurs here
LL |
LL | f();
| - immutable borrow later used here
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-closures-slice-patterns.rs:16:13
|
LL | let mut f = || {
| -- mutable borrow occurs here
LL | let [ref mut y, ref mut z @ ..] = x;
| - first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &x;
| ^^ immutable borrow occurs here
LL |
LL | f();
| - mutable borrow later used here
error[E0382]: borrow of moved value: `x`
--> $DIR/borrowck-closures-slice-patterns.rs:25:5
|
LL | fn arr_by_move(x: [String; 3]) {
| - move occurs because `x` has type `[String; 3]`, which does not implement the `Copy` trait
LL | let f = || {
| -- value moved into closure here
LL | let [y, z @ ..] = x;
| - variable moved due to use in closure
LL | };
LL | &x;
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL | let [y, z @ ..] = x.clone();
| ++++++++
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-closures-slice-patterns.rs:33:13
|
LL | let f = || {
| -- immutable borrow occurs here
LL | let [ref y, ref z @ ..] = *x;
| -- first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &mut *x;
| ^^^^^^^ mutable borrow occurs here
LL |
LL | f();
| - immutable borrow later used here
error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
--> $DIR/borrowck-closures-slice-patterns.rs:42:13
|
LL | let mut f = || {
| -- closure construction occurs here
LL | let [ref mut y, ref mut z @ ..] = *x;
| -- first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &x;
| ^^ second borrow occurs here
LL |
LL | f();
| - first borrow later used here
error[E0382]: borrow of moved value: `x`
--> $DIR/borrowck-closures-slice-patterns.rs:51:5
|
LL | fn arr_box_by_move(x: Box<[String; 3]>) {
| - move occurs because `x` has type `Box<[String; 3]>`, which does not implement the `Copy` trait
LL | let f = || {
| -- value moved into closure here
LL | let [y, z @ ..] = *x;
| -- variable moved due to use in closure
LL | };
LL | &x;
| ^^ value borrowed here after move
|
help: consider cloning the value if the performance cost is acceptable
|
LL - let [y, z @ ..] = *x;
LL + let [y, z @ ..] = x.clone();
|
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-closures-slice-patterns.rs:59:13
|
LL | let f = || {
| -- immutable borrow occurs here
LL | if let [ref y, ref z @ ..] = *x {}
| -- first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &mut *x;
| ^^^^^^^ mutable borrow occurs here
LL |
LL | f();
| - immutable borrow later used here
error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
--> $DIR/borrowck-closures-slice-patterns.rs:68:13
|
LL | let mut f = || {
| -- closure construction occurs here
LL | if let [ref mut y, ref mut z @ ..] = *x {}
| -- first borrow occurs due to use of `x` in closure
LL | };
LL | let r = &x;
| ^^ second borrow occurs here
LL |
LL | f();
| - first borrow later used here
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0382, E0501, E0502.
For more information about an error, try `rustc --explain E0382`.
|