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