]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/borrowck-call-is-borrow-issue-12224.stderr
Auto merge of #88988 - Mark-Simulacrum:avoid-into-ok, r=nagisa
[rust.git] / src / test / ui / span / borrowck-call-is-borrow-issue-12224.stderr
1 error[E0499]: cannot borrow `f` as mutable more than once at a time
2   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:12:16
3    |
4 LL |     f(Box::new(|| {
5    |     -          ^^ second mutable borrow occurs here
6    |     |
7    |     first mutable borrow occurs here
8    |     first borrow later used by call
9 LL |
10 LL |         f((Box::new(|| {})))
11    |         - second borrow occurs due to use of `f` in closure
12
13 error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference
14   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5
15    |
16 LL | fn test2<F>(f: &F) where F: FnMut() {
17    |                -- help: consider changing this to be a mutable reference: `&mut F`
18 LL |     (*f)();
19    |     ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
20
21 error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
22   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
23    |
24 LL | fn test4(f: &Test) {
25    |             ----- help: consider changing this to be a mutable reference: `&mut Test<'_>`
26 LL |     f.f.call_mut(())
27    |     ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
28
29 error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
30   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
31    |
32 LL |       let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
33    |           ----- captured outer variable
34 ...
35 LL |       f(Box::new(|a| {
36    |  ________________-
37 LL | |
38 LL | |         foo(f);
39    | |             ^ move occurs because `f` has type `[closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 54:6]`, which does not implement the `Copy` trait
40 LL | |
41 LL | |     }), 3);
42    | |_____- captured by this `FnMut` closure
43
44 error[E0505]: cannot move out of `f` because it is borrowed
45   --> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16
46    |
47 LL |     f(Box::new(|a| {
48    |     -          ^^^ move out of `f` occurs here
49    |     |
50    |     borrow of `f` occurs here
51 LL |
52 LL |         foo(f);
53    |             - move occurs due to use in closure
54
55 error: aborting due to 5 previous errors
56
57 Some errors have detailed explanations: E0499, E0505, E0507, E0596.
58 For more information about an error, try `rustc --explain E0499`.