File: borrowck-unboxed-closures.stderr

package info (click to toggle)
rustc 1.89.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 906,624 kB
  • sloc: xml: 158,148; python: 34,888; javascript: 19,595; sh: 19,221; ansic: 13,046; cpp: 7,144; asm: 4,376; makefile: 692; lisp: 174; sql: 15
file content (43 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
  --> $DIR/borrowck-unboxed-closures.rs:3:5
   |
LL |     let g = &mut f;
   |             ------ mutable borrow occurs here
LL |     f(1, 2);
   |     ^ immutable borrow occurs here
LL |     use_mut(g);
   |             - mutable borrow later used here

error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
  --> $DIR/borrowck-unboxed-closures.rs:7:5
   |
LL |     f(1, 2);
   |     ^ cannot borrow as mutable
   |
help: consider changing this to be mutable
   |
LL | fn b<F:FnMut(isize, isize) -> isize>(mut f: F) {
   |                                      +++

error[E0382]: use of moved value: `f`
  --> $DIR/borrowck-unboxed-closures.rs:12:5
   |
LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
   |                                       - move occurs because `f` has type `F`, which does not implement the `Copy` trait
LL |     f(1, 2);
   |     ------- `f` moved due to this call
LL |     f(1, 2);
   |     ^ value used here after move
   |
note: `FnOnce` closures can only be called once
  --> $DIR/borrowck-unboxed-closures.rs:10:8
   |
LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `F` is made to be an `FnOnce` closure here
LL |     f(1, 2);
   |     ------- this value implements `FnOnce`, which causes it to be moved when called

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0382, E0502, E0596.
For more information about an error, try `rustc --explain E0382`.