2019-05-02 17:34:15 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-closures-two-mut.rs:12:24
|
2017-11-11 03:15:26 -06:00
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 4);
|
2018-08-01 15:02:10 -05:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let c2 = to_fn_mut(|| x = 5);
|
2018-08-01 15:02:10 -05:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 04:28:00 -05:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- first borrow later used here
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2019-05-02 17:34:15 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-closures-two-mut.rs:23:24
|
2017-11-11 03:15:26 -06:00
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut x));
|
2018-08-01 15:02:10 -05:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x));
|
2018-08-01 15:02:10 -05:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 04:28:00 -05:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- first borrow later used here
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2019-05-02 17:34:15 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-closures-two-mut.rs:30:24
|
2017-11-11 03:15:26 -06:00
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
2018-08-01 15:02:10 -05:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x));
|
2018-08-01 15:02:10 -05:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 04:28:00 -05:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- first borrow later used here
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2019-05-02 17:34:15 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-closures-two-mut.rs:37:24
|
2017-11-11 03:15:26 -06:00
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
2018-08-01 15:02:10 -05:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
|
2018-08-01 15:02:10 -05:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2019-05-02 17:34:15 -05:00
|
|
|
LL |
|
2018-04-09 04:28:00 -05:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- first borrow later used here
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2019-05-02 17:34:15 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-closures-two-mut.rs:49:24
|
2017-11-11 03:15:26 -06:00
|
|
|
|
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
2021-03-17 01:51:27 -05:00
|
|
|
| -- ---- first borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2018-02-22 18:42:32 -06:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
|
2021-03-17 01:51:27 -05:00
|
|
|
| ^^ ---- second borrow occurs due to use of `x` in closure
|
2017-11-11 03:15:26 -06:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2019-05-02 17:34:15 -05:00
|
|
|
LL |
|
2018-04-09 04:28:00 -05:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 05:47:47 -05:00
|
|
|
| -- first borrow later used here
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2019-05-02 17:34:15 -05:00
|
|
|
error: aborting due to 5 previous errors
|
2017-11-11 03:15:26 -06:00
|
|
|
|
2018-03-03 08:59:40 -06:00
|
|
|
For more information about this error, try `rustc --explain E0499`.
|