2018-08-08 07:28:26 -05:00
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2018-08-08 07:50:16 -05:00
|
|
|
--> $DIR/borrowck-closures-two-mut-fail.rs:26:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let c1 = to_fn_mut(|| x = 4);
|
|
|
|
| -- - previous borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
|
|
|
|
| ^^ - borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | }
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2018-08-08 07:50:16 -05:00
|
|
|
--> $DIR/borrowck-closures-two-mut-fail.rs:36:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut x));
|
|
|
|
| -- - previous borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
|
|
|
| ^^ - borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | }
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2018-08-08 07:50:16 -05:00
|
|
|
--> $DIR/borrowck-closures-two-mut-fail.rs:42:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
|
|
|
| -- - previous borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
|
|
|
| ^^ - borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | }
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2018-08-08 07:50:16 -05:00
|
|
|
--> $DIR/borrowck-closures-two-mut-fail.rs:48:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let c1 = to_fn_mut(|| x = 5);
|
|
|
|
| -- - previous borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
|
|
|
|
| ^^ - borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | //~^ ERROR cannot borrow `x` as mutable more than once
|
|
|
|
LL | }
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error[E0499]: cannot borrow `x` as mutable more than once at a time
|
2018-08-08 07:50:16 -05:00
|
|
|
--> $DIR/borrowck-closures-two-mut-fail.rs:59:24
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
|
|
|
| -- - previous borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
|
|
|
|
| ^^ - borrow occurs due to use of `x` in closure
|
|
|
|
| |
|
|
|
|
| second mutable borrow occurs here
|
|
|
|
LL | //~^ ERROR cannot borrow `x` as mutable more than once
|
|
|
|
LL | }
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error: aborting due to 5 previous errors
|
|
|
|
|
|
|
|
For more information about this error, try `rustc --explain E0499`.
|