fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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