]> git.lizzy.rs Git - rust.git/blob - src/test/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr
Fix incorrect use mut diagnostics
[rust.git] / src / test / ui / closures / 2229_closure_analysis / diagnostics / arrays.stderr
1 warning: the feature `capture_disjoint_fields` is incomplete and may not be safe to use and/or cause compiler crashes
2   --> $DIR/arrays.rs:3:12
3    |
4 LL | #![feature(capture_disjoint_fields)]
5    |            ^^^^^^^^^^^^^^^^^^^^^^^
6    |
7    = note: `#[warn(incomplete_features)]` on by default
8    = note: see issue #53488 <https://github.com/rust-lang/rust/issues/53488> for more information
9
10 error[E0503]: cannot use `arr` because it was mutably borrowed
11   --> $DIR/arrays.rs:15:5
12    |
13 LL |     let mut c = || {
14    |                 -- borrow of `arr` occurs here
15 LL |         arr[0] += 10;
16    |         --- borrow occurs due to use of `arr` in closure
17 ...
18 LL |     arr[1] += 10;
19    |     ^^^^^^ use of borrowed `arr`
20 ...
21 LL |     c();
22    |     - borrow later used here
23
24 error[E0503]: cannot use `arr[_]` because it was mutably borrowed
25   --> $DIR/arrays.rs:15:5
26    |
27 LL |     let mut c = || {
28    |                 -- borrow of `arr` occurs here
29 LL |         arr[0] += 10;
30    |         --- borrow occurs due to use of `arr` in closure
31 ...
32 LL |     arr[1] += 10;
33    |     ^^^^^^^^^^^^ use of borrowed `arr`
34 ...
35 LL |     c();
36    |     - borrow later used here
37
38 error[E0506]: cannot assign to `arr[_]` because it is borrowed
39   --> $DIR/arrays.rs:30:5
40    |
41 LL |     let c = || {
42    |             -- borrow of `arr[_]` occurs here
43 LL |         println!("{:#?}", &arr[3..4]);
44    |                            --- borrow occurs due to use in closure
45 ...
46 LL |     arr[1] += 10;
47    |     ^^^^^^^^^^^^ assignment to borrowed `arr[_]` occurs here
48 LL |
49 LL |     c();
50    |     - borrow later used here
51
52 error[E0506]: cannot assign to `arr[_]` because it is borrowed
53   --> $DIR/arrays.rs:44:5
54    |
55 LL |     let c = || {
56    |             -- borrow of `arr[_]` occurs here
57 LL |         println!("{}", arr[3]);
58    |                        --- borrow occurs due to use in closure
59 ...
60 LL |     arr[1] += 10;
61    |     ^^^^^^^^^^^^ assignment to borrowed `arr[_]` occurs here
62 LL |
63 LL |     c();
64    |     - borrow later used here
65
66 error[E0503]: cannot use `arr` because it was mutably borrowed
67   --> $DIR/arrays.rs:58:20
68    |
69 LL |     let mut c = || {
70    |                 -- borrow of `arr` occurs here
71 LL |         arr[1] += 10;
72    |         --- borrow occurs due to use of `arr` in closure
73 ...
74 LL |     println!("{}", arr[3]);
75    |                    ^^^^^^ use of borrowed `arr`
76 ...
77 LL |     c();
78    |     - borrow later used here
79
80 error[E0502]: cannot borrow `arr[_]` as immutable because it is also borrowed as mutable
81   --> $DIR/arrays.rs:58:20
82    |
83 LL |     let mut c = || {
84    |                 -- mutable borrow occurs here
85 LL |         arr[1] += 10;
86    |         --- first borrow occurs due to use of `arr` in closure
87 ...
88 LL |     println!("{}", arr[3]);
89    |                    ^^^^^^ immutable borrow occurs here
90 ...
91 LL |     c();
92    |     - mutable borrow later used here
93
94 error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable
95   --> $DIR/arrays.rs:74:24
96    |
97 LL |     let mut c = || {
98    |                 -- mutable borrow occurs here
99 LL |         arr[1] += 10;
100    |         --- first borrow occurs due to use of `arr` in closure
101 ...
102 LL |     println!("{:#?}", &arr[3..2]);
103    |                        ^^^ immutable borrow occurs here
104 ...
105 LL |     c();
106    |     - mutable borrow later used here
107
108 error: aborting due to 7 previous errors; 1 warning emitted
109
110 Some errors have detailed explanations: E0502, E0503, E0506.
111 For more information about an error, try `rustc --explain E0502`.