rust/src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr
Esteban Küber 6384568fdb Reword trying to operate in immutable fields
The previous message ("cannot assign/mutably borrow immutable field")
when trying to modify a field of an immutable binding gave the
(incorrect) impression that fields can be mutable independently of their
ADT's binding. Slightly reword the message to read "cannot
assign/mutably borrow field of immutable binding".
2017-12-31 15:32:41 -08:00

49 lines
1.7 KiB
Plaintext

error[E0499]: cannot borrow `f` as mutable more than once at a time
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:22:16
|
22 | f(Box::new(|| {
| - ^^ second mutable borrow occurs here
| |
| first mutable borrow occurs here
23 | //~^ ERROR: cannot borrow `f` as mutable more than once
24 | f((Box::new(|| {})))
| - borrow occurs due to use of `f` in closure
25 | }));
| - first borrow ends here
error[E0596]: cannot borrow immutable borrowed content `*f` as mutable
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:35:5
|
34 | fn test2<F>(f: &F) where F: FnMut() {
| -- use `&mut F` here to make mutable
35 | (*f)();
| ^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `Box` content `*f.f` of immutable binding as mutable
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:44:5
|
43 | fn test4(f: &Test) {
| ----- use `&mut Test` here to make mutable
44 | f.f.call_mut(())
| ^^^ cannot borrow as mutable
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
|
61 | let mut f = |g: Box<FnMut(isize)>, b: isize| {};
| ----- captured outer variable
62 | f(Box::new(|a| {
63 | foo(f);
| ^ cannot move out of captured outer variable in an `FnMut` closure
error: aborting due to 5 previous errors