]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closure-access-spans.stderr
Rollup merge of #103644 - catlee:catlee/option-question-mark-docs, r=workingjubilee
[rust.git] / src / test / ui / nll / closure-access-spans.stderr
1 error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
2   --> $DIR/closure-access-spans.rs:5:5
3    |
4 LL |     let r = &mut x;
5    |             ------ mutable borrow occurs here
6 LL |     || x;
7    |     ^^ - second borrow occurs due to use of `x` in closure
8    |     |
9    |     immutable borrow occurs here
10 LL |     r.use_mut();
11    |     ----------- mutable borrow later used here
12
13 error[E0499]: cannot borrow `x` as mutable more than once at a time
14   --> $DIR/closure-access-spans.rs:11:5
15    |
16 LL |     let r = &mut x;
17    |             ------ first mutable borrow occurs here
18 LL |     || x = 2;
19    |     ^^ - second borrow occurs due to use of `x` in closure
20    |     |
21    |     second mutable borrow occurs here
22 LL |     r.use_mut();
23    |     ----------- first borrow later used here
24
25 error[E0500]: closure requires unique access to `x` but it is already borrowed
26   --> $DIR/closure-access-spans.rs:17:5
27    |
28 LL |     let r = &mut x;
29    |             ------ borrow occurs here
30 LL |     || *x = 2;
31    |     ^^ -- second borrow occurs due to use of `x` in closure
32    |     |
33    |     closure construction occurs here
34 LL |     r.use_mut();
35    |     ----------- first borrow later used here
36
37 error[E0503]: cannot use `x` because it was mutably borrowed
38   --> $DIR/closure-access-spans.rs:23:13
39    |
40 LL |     let r = &mut x;
41    |             ------ borrow of `x` occurs here
42 LL |     move || x;
43    |             ^ use of borrowed `x`
44 LL |     r.use_ref();
45    |     ----------- borrow later used here
46
47 error[E0505]: cannot move out of `x` because it is borrowed
48   --> $DIR/closure-access-spans.rs:29:5
49    |
50 LL |     let r = &x;
51    |             -- borrow of `x` occurs here
52 LL |     || x;
53    |     ^^ - move occurs due to use in closure
54    |     |
55    |     move out of `x` occurs here
56 LL |     r.use_ref();
57    |     ----------- borrow later used here
58
59 error[E0382]: borrow of moved value: `x`
60   --> $DIR/closure-access-spans.rs:35:5
61    |
62 LL | fn closure_imm_capture_moved(mut x: String) {
63    |                              ----- move occurs because `x` has type `String`, which does not implement the `Copy` trait
64 LL |     let r = x;
65    |             - value moved here
66 LL |     || x.len();
67    |     ^^ - borrow occurs due to use in closure
68    |     |
69    |     value borrowed here after move
70    |
71 help: consider cloning the value if the performance cost is acceptable
72    |
73 LL |     let r = x.clone();
74    |              ++++++++
75
76 error[E0382]: borrow of moved value: `x`
77   --> $DIR/closure-access-spans.rs:40:5
78    |
79 LL | fn closure_mut_capture_moved(mut x: String) {
80    |                              ----- move occurs because `x` has type `String`, which does not implement the `Copy` trait
81 LL |     let r = x;
82    |             - value moved here
83 LL |     || x = String::new();
84    |     ^^ - borrow occurs due to use in closure
85    |     |
86    |     value borrowed here after move
87    |
88 help: consider cloning the value if the performance cost is acceptable
89    |
90 LL |     let r = x.clone();
91    |              ++++++++
92
93 error[E0382]: borrow of moved value: `x`
94   --> $DIR/closure-access-spans.rs:45:5
95    |
96 LL | fn closure_unique_capture_moved(x: &mut String) {
97    |                                 - move occurs because `x` has type `&mut String`, which does not implement the `Copy` trait
98 LL |     let r = x;
99    |             - value moved here
100 LL |     || *x = String::new();
101    |     ^^ -- borrow occurs due to use in closure
102    |     |
103    |     value borrowed here after move
104
105 error[E0382]: use of moved value: `x`
106   --> $DIR/closure-access-spans.rs:50:5
107    |
108 LL | fn closure_move_capture_moved(x: &mut String) {
109    |                               - move occurs because `x` has type `&mut String`, which does not implement the `Copy` trait
110 LL |     let r = x;
111    |             - value moved here
112 LL |     || x;
113    |     ^^ - use occurs due to use in closure
114    |     |
115    |     value used here after move
116
117 error: aborting due to 9 previous errors
118
119 Some errors have detailed explanations: E0382, E0499, E0500, E0502, E0503, E0505.
120 For more information about an error, try `rustc --explain E0382`.