rust/tests/ui/borrowck/borrowck-closures-slice-patterns.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
4.5 KiB
Plaintext
Raw Normal View History

2019-12-15 10:14:24 -06:00
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:7:13
2019-12-15 10:14:24 -06:00
|
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
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:16:13
2019-12-15 10:14:24 -06:00
|
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`
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:25:5
2019-12-15 10:14:24 -06:00
|
LL | fn arr_by_move(x: [String; 3]) {
| - move occurs because `x` has type `[String; 3]`, which does not implement the `Copy` trait
2019-12-15 10:14:24 -06:00
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();
| ++++++++
2019-12-15 10:14:24 -06:00
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:33:13
2019-12-15 10:14:24 -06:00
|
LL | let f = || {
| -- immutable borrow occurs here
LL | let [ref y, ref z @ ..] = *x;
| -- first borrow occurs due to use of `x` in closure
2019-12-15 10:14:24 -06:00
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
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:42:13
2019-12-15 10:14:24 -06:00
|
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
2019-12-15 10:14:24 -06:00
LL | };
LL | let r = &x;
| ^^ second borrow occurs here
LL |
LL | f();
| - first borrow later used here
error[E0382]: borrow of moved value: `x`
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:51:5
2019-12-15 10:14:24 -06:00
|
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
2019-12-15 10:14:24 -06:00
LL | let f = || {
| -- value moved into closure here
LL | let [y, z @ ..] = *x;
| -- variable moved due to use in closure
2019-12-15 10:14:24 -06:00
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();
|
2019-12-15 10:14:24 -06:00
error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:59:13
2019-12-15 10:14:24 -06:00
|
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
2019-12-15 10:14:24 -06:00
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
2019-12-29 18:23:42 -06:00
--> $DIR/borrowck-closures-slice-patterns.rs:68:13
2019-12-15 10:14:24 -06:00
|
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
2019-12-15 10:14:24 -06:00
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`.