2016-11-08 00:21:53 -06:00
|
|
|
error[E0499]: cannot borrow `f` as mutable more than once at a time
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:23:16
|
|
|
|
|
|
|
|
|
23 | f(Box::new(|| {
|
|
|
|
| - ^^ second mutable borrow occurs here
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
|
|
|
24 | //~^ ERROR: cannot borrow `f` as mutable more than once
|
|
|
|
25 | f((Box::new(|| {})))
|
|
|
|
| - borrow occurs due to use of `f` in closure
|
|
|
|
26 | }));
|
|
|
|
| - first borrow ends here
|
|
|
|
|
|
|
|
error: cannot borrow immutable borrowed content `*f` as mutable
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:36:5
|
|
|
|
|
|
|
|
|
35 | fn test2<F>(f: &F) where F: FnMut() {
|
|
|
|
| -- use `&mut F` here to make mutable
|
|
|
|
36 | (*f)(); //~ ERROR: cannot borrow immutable borrowed content `*f` as mutable
|
2017-01-17 01:42:11 -06:00
|
|
|
| ^^^^ cannot borrow as mutable
|
2016-11-08 00:21:53 -06:00
|
|
|
|
|
|
|
error: cannot borrow immutable `Box` content `*f.f` as mutable
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:44:5
|
|
|
|
|
|
2017-01-17 01:42:11 -06:00
|
|
|
43 | fn test4(f: &Test) {
|
|
|
|
| ----- use `&mut Test` here to make mutable
|
2016-11-08 00:21:53 -06:00
|
|
|
44 | f.f.call_mut(()) //~ ERROR: cannot borrow immutable `Box` content `*f.f` as mutable
|
2017-01-17 01:42:11 -06:00
|
|
|
| ^^^ cannot borrow as mutable
|
2016-11-08 00:21:53 -06:00
|
|
|
|
|
|
|
error[E0504]: cannot move `f` into closure because it is borrowed
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13
|
|
|
|
|
|
|
|
|
62 | f(Box::new(|a| {
|
|
|
|
| - borrow of `f` occurs here
|
|
|
|
63 | foo(f);
|
|
|
|
| ^ move into closure occurs here
|
|
|
|
|
|
|
|
error[E0507]: cannot move out of captured outer variable in an `FnMut` closure
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:63:13
|
|
|
|
|
|
|
|
|
63 | foo(f);
|
|
|
|
| ^ cannot move out of captured outer variable in an `FnMut` closure
|
|
|
|
|
|
|
|
error: aborting due to 5 previous errors
|
|
|
|
|