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