]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/borrowck-closures-slice-patterns.stderr
Rollup merge of #102500 - compiler-errors:parse-sess-cleanup, r=cjgillot
[rust.git] / src / test / ui / borrowck / borrowck-closures-slice-patterns.stderr
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]) {
33    |                - move occurs because `x` has type `[String; 3]`, which does not implement the `Copy` trait
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;
48    |                                   -- first borrow occurs due to use of `x` in closure
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;
62    |                                           -- first borrow occurs due to use of `x` in closure
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]>) {
74    |                    - move occurs because `x` has type `Box<[String; 3]>`, which does not implement the `Copy` trait
75 LL |     let f = || {
76    |             -- value moved into closure here
77 LL |         let [y, z @ ..] = *x;
78    |                           -- variable moved due to use in closure
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 {}
89    |                                      -- first borrow occurs due to use of `x` in closure
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 {}
103    |                                              -- first borrow occurs due to use of `x` in closure
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`.