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