2018-08-01 19:40:06 +00:00
|
|
|
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:5:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
|
LL | let r = &mut x;
|
|
|
|
| ------ mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x;
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| immutable borrow occurs here
|
|
|
|
LL | r.use_mut();
|
2023-06-22 20:30:23 +00:00
|
|
|
| - mutable borrow later used here
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:11:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
|
LL | let r = &mut x;
|
|
|
|
| ------ first mutable borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x = 2;
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | r.use_mut();
|
2023-06-22 20:30:23 +00:00
|
|
|
| - first borrow later used here
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0500]: closure requires unique access to `x` but it is already borrowed
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:17:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
|
LL | let r = &mut x;
|
|
|
|
| ------ borrow occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || *x = 2;
|
2021-03-17 06:51:27 +00:00
|
|
|
| ^^ -- second borrow occurs due to use of `x` in closure
|
2018-08-01 19:40:06 +00:00
|
|
|
| |
|
|
|
|
| closure construction occurs here
|
|
|
|
LL | r.use_mut();
|
2023-06-22 20:30:23 +00:00
|
|
|
| - first borrow later used here
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0503]: cannot use `x` because it was mutably borrowed
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:23:13
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
|
LL | let r = &mut x;
|
2023-01-15 03:06:44 +00:00
|
|
|
| ------ `x` is borrowed here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | move || x;
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^ use of borrowed `x`
|
|
|
|
LL | r.use_ref();
|
2023-06-22 20:30:23 +00:00
|
|
|
| - borrow later used here
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0505]: cannot move out of `x` because it is borrowed
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:29:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
2023-01-15 03:06:44 +00:00
|
|
|
LL | fn closure_move_capture_conflict(mut x: String) {
|
|
|
|
| ----- binding `x` declared here
|
2018-08-01 19:40:06 +00:00
|
|
|
LL | let r = &x;
|
|
|
|
| -- borrow of `x` occurs here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x;
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - move occurs due to use in closure
|
|
|
|
| |
|
|
|
|
| move out of `x` occurs here
|
|
|
|
LL | r.use_ref();
|
2023-06-22 20:30:23 +00:00
|
|
|
| - borrow later used here
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0382]: borrow of moved value: `x`
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:35:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
2019-01-03 00:43:08 +00:00
|
|
|
LL | fn closure_imm_capture_moved(mut x: String) {
|
2020-09-02 07:40:56 +00:00
|
|
|
| ----- move occurs because `x` has type `String`, which does not implement the `Copy` trait
|
2018-08-01 19:40:06 +00:00
|
|
|
LL | let r = x;
|
|
|
|
| - value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x.len();
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - borrow occurs due to use in closure
|
|
|
|
| |
|
|
|
|
| value borrowed here after move
|
2022-11-03 04:22:24 +00:00
|
|
|
|
|
|
|
|
help: consider cloning the value if the performance cost is acceptable
|
|
|
|
|
|
|
|
|
LL | let r = x.clone();
|
|
|
|
| ++++++++
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0382]: borrow of moved value: `x`
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:40:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
2019-01-03 00:43:08 +00:00
|
|
|
LL | fn closure_mut_capture_moved(mut x: String) {
|
2020-09-02 07:40:56 +00:00
|
|
|
| ----- move occurs because `x` has type `String`, which does not implement the `Copy` trait
|
2018-08-01 19:40:06 +00:00
|
|
|
LL | let r = x;
|
|
|
|
| - value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x = String::new();
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - borrow occurs due to use in closure
|
|
|
|
| |
|
|
|
|
| value borrowed here after move
|
2022-11-03 04:22:24 +00:00
|
|
|
|
|
|
|
|
help: consider cloning the value if the performance cost is acceptable
|
|
|
|
|
|
|
|
|
LL | let r = x.clone();
|
|
|
|
| ++++++++
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
|
|
error[E0382]: borrow of moved value: `x`
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:45:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
2019-01-03 00:43:08 +00:00
|
|
|
LL | fn closure_unique_capture_moved(x: &mut String) {
|
2020-09-02 07:40:56 +00:00
|
|
|
| - move occurs because `x` has type `&mut String`, which does not implement the `Copy` trait
|
2018-08-01 19:40:06 +00:00
|
|
|
LL | let r = x;
|
|
|
|
| - value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || *x = String::new();
|
2021-03-17 06:51:27 +00:00
|
|
|
| ^^ -- borrow occurs due to use in closure
|
2018-08-01 19:40:06 +00:00
|
|
|
| |
|
|
|
|
| value borrowed here after move
|
|
|
|
|
|
|
|
error[E0382]: use of moved value: `x`
|
2019-04-07 15:07:36 +00:00
|
|
|
--> $DIR/closure-access-spans.rs:50:5
|
2018-08-01 19:40:06 +00:00
|
|
|
|
|
2019-01-03 00:43:08 +00:00
|
|
|
LL | fn closure_move_capture_moved(x: &mut String) {
|
2020-09-02 07:40:56 +00:00
|
|
|
| - move occurs because `x` has type `&mut String`, which does not implement the `Copy` trait
|
2018-08-01 19:40:06 +00:00
|
|
|
LL | let r = x;
|
|
|
|
| - value moved here
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | || x;
|
2018-08-01 19:40:06 +00:00
|
|
|
| ^^ - use occurs due to use in closure
|
|
|
|
| |
|
|
|
|
| value used here after move
|
|
|
|
|
|
|
|
error: aborting due to 9 previous errors
|
|
|
|
|
2019-04-17 17:26:38 +00:00
|
|
|
Some errors have detailed explanations: E0382, E0499, E0500, E0502, E0503, E0505.
|
2018-08-01 19:40:06 +00:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|