]> git.lizzy.rs Git - rust.git/blob - tests/ui/closures/2229_closure_analysis/diagnostics/arrays.stderr
Rollup merge of #107100 - compiler-errors:issue-107087, r=lcnr
[rust.git] / tests / ui / closures / 2229_closure_analysis / diagnostics / arrays.stderr
1 error[E0503]: cannot use `arr` because it was mutably borrowed
2   --> $DIR/arrays.rs:14:5
3    |
4 LL |     let mut c = || {
5    |                 -- `arr` is borrowed here
6 LL |         arr[0] += 10;
7    |         --- borrow occurs due to use of `arr` in closure
8 ...
9 LL |     arr[1] += 10;
10    |     ^^^^^^ use of borrowed `arr`
11 ...
12 LL |     c();
13    |     - borrow later used here
14
15 error[E0503]: cannot use `arr[_]` because it was mutably borrowed
16   --> $DIR/arrays.rs:14:5
17    |
18 LL |     let mut c = || {
19    |                 -- `arr` is borrowed here
20 LL |         arr[0] += 10;
21    |         --- borrow occurs due to use of `arr` in closure
22 ...
23 LL |     arr[1] += 10;
24    |     ^^^^^^^^^^^^ use of borrowed `arr`
25 ...
26 LL |     c();
27    |     - borrow later used here
28
29 error[E0506]: cannot assign to `arr[_]` because it is borrowed
30   --> $DIR/arrays.rs:29:5
31    |
32 LL |     let c = || {
33    |             -- `arr[_]` is borrowed here
34 LL |         println!("{:#?}", &arr[3..4]);
35    |                            --- borrow occurs due to use in closure
36 ...
37 LL |     arr[1] += 10;
38    |     ^^^^^^^^^^^^ `arr[_]` is assigned to here but it was already borrowed
39 LL |
40 LL |     c();
41    |     - borrow later used here
42
43 error[E0506]: cannot assign to `arr[_]` because it is borrowed
44   --> $DIR/arrays.rs:43:5
45    |
46 LL |     let c = || {
47    |             -- `arr[_]` is borrowed here
48 LL |         println!("{}", arr[3]);
49    |                        --- borrow occurs due to use in closure
50 ...
51 LL |     arr[1] += 10;
52    |     ^^^^^^^^^^^^ `arr[_]` is assigned to here but it was already borrowed
53 LL |
54 LL |     c();
55    |     - borrow later used here
56
57 error[E0503]: cannot use `arr` because it was mutably borrowed
58   --> $DIR/arrays.rs:57:20
59    |
60 LL |     let mut c = || {
61    |                 -- `arr` is borrowed here
62 LL |         arr[1] += 10;
63    |         --- borrow occurs due to use of `arr` in closure
64 ...
65 LL |     println!("{}", arr[3]);
66    |                    ^^^^^^ use of borrowed `arr`
67 ...
68 LL |     c();
69    |     - borrow later used here
70
71 error[E0502]: cannot borrow `arr[_]` as immutable because it is also borrowed as mutable
72   --> $DIR/arrays.rs:57:20
73    |
74 LL |     let mut c = || {
75    |                 -- mutable borrow occurs here
76 LL |         arr[1] += 10;
77    |         --- first borrow occurs due to use of `arr` in closure
78 ...
79 LL |     println!("{}", arr[3]);
80    |                    ^^^^^^ immutable borrow occurs here
81 ...
82 LL |     c();
83    |     - mutable borrow later used here
84    |
85    = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
86
87 error[E0502]: cannot borrow `arr` as immutable because it is also borrowed as mutable
88   --> $DIR/arrays.rs:73:24
89    |
90 LL |     let mut c = || {
91    |                 -- mutable borrow occurs here
92 LL |         arr[1] += 10;
93    |         --- first borrow occurs due to use of `arr` in closure
94 ...
95 LL |     println!("{:#?}", &arr[3..2]);
96    |                        ^^^ immutable borrow occurs here
97 ...
98 LL |     c();
99    |     - mutable borrow later used here
100
101 error: aborting due to 7 previous errors
102
103 Some errors have detailed explanations: E0502, E0503, E0506.
104 For more information about an error, try `rustc --explain E0502`.