2019-05-02 18:34:15 -04: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 18:15:26 +09:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 4);
|
2018-08-01 21:02:10 +01:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | let c2 = to_fn_mut(|| x = 5);
|
2018-08-01 21:02:10 +01:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 05:28:00 -04:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 11:47:47 +01:00
|
|
|
| -- first borrow later used here
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2019-05-02 18:34:15 -04: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 18:15:26 +09:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut x));
|
2018-08-01 21:02:10 +01:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x));
|
2018-08-01 21:02:10 +01:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 05:28:00 -04:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 11:47:47 +01:00
|
|
|
| -- first borrow later used here
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2019-05-02 18:34:15 -04: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 18:15:26 +09:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
2018-08-01 21:02:10 +01:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-03-09 15:03:44 +03:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x));
|
2018-08-01 21:02:10 +01:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2018-04-09 05:28:00 -04:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 11:47:47 +01:00
|
|
|
| -- first borrow later used here
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2019-05-02 18:34:15 -04: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 18:15:26 +09:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
2018-08-01 21:02:10 +01:00
|
|
|
| -- - first borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
|
2018-08-01 21:02:10 +01:00
|
|
|
| ^^ - second borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2019-05-02 18:34:15 -04:00
|
|
|
LL |
|
2018-04-09 05:28:00 -04:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 11:47:47 +01:00
|
|
|
| -- first borrow later used here
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2019-05-02 18:34:15 -04: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 18:15:26 +09:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
2021-03-17 02:51:27 -04:00
|
|
|
| -- ---- first borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
|
2021-03-17 02:51:27 -04:00
|
|
|
| ^^ ---- second borrow occurs due to use of `x` in closure
|
2017-11-11 18:15:26 +09:00
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
2019-05-02 18:34:15 -04:00
|
|
|
LL |
|
2018-04-09 05:28:00 -04:00
|
|
|
LL | drop((c1, c2));
|
2018-09-29 11:47:47 +01:00
|
|
|
| -- first borrow later used here
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2019-05-02 18:34:15 -04:00
|
|
|
error: aborting due to 5 previous errors
|
2017-11-11 18:15:26 +09:00
|
|
|
|
2018-03-03 15:59:40 +01:00
|
|
|
For more information about this error, try `rustc --explain E0499`.
|