fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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