2018-08-08 07:28:26 -05:00
|
|
|
error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-unboxed-closures.rs:3:5
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let g = &mut f;
|
2019-04-22 02:40:08 -05:00
|
|
|
| ------ mutable borrow occurs here
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | f(1, 2);
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^ immutable borrow occurs here
|
2018-11-05 07:32:00 -06:00
|
|
|
LL | use_mut(g);
|
2019-04-22 02:40:08 -05:00
|
|
|
| - mutable borrow later used here
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2019-04-22 02:40:08 -05:00
|
|
|
error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-unboxed-closures.rs:7:5
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | f(1, 2);
|
2019-04-22 02:40:08 -05:00
|
|
|
| ^ cannot borrow as mutable
|
2023-01-01 02:06:31 -06:00
|
|
|
|
|
|
|
|
help: consider changing this to be mutable
|
|
|
|
|
|
|
|
|
LL | fn b<F:FnMut(isize, isize) -> isize>(mut f: F) {
|
|
|
|
| +++
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0382]: use of moved value: `f`
|
2018-12-25 09:56:47 -06:00
|
|
|
--> $DIR/borrowck-unboxed-closures.rs:12:5
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-04-22 02:40:08 -05:00
|
|
|
LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
|
2019-12-26 06:43:33 -06:00
|
|
|
| - move occurs because `f` has type `F`, which does not implement the `Copy` trait
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | f(1, 2);
|
2020-06-11 12:48:46 -05:00
|
|
|
| ------- `f` moved due to this call
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | f(1, 2);
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^ value used here after move
|
2019-12-26 06:43:33 -06:00
|
|
|
|
|
2020-06-11 12:48:46 -05:00
|
|
|
note: this value implements `FnOnce`, which causes it to be moved when called
|
|
|
|
--> $DIR/borrowck-unboxed-closures.rs:11:5
|
|
|
|
|
|
|
|
|
LL | f(1, 2);
|
|
|
|
| ^
|
2020-03-13 21:28:14 -05:00
|
|
|
help: consider further restricting this bound
|
2019-12-26 06:43:33 -06:00
|
|
|
|
|
2020-03-13 21:28:14 -05:00
|
|
|
LL | fn c<F:FnOnce(isize, isize) -> isize + Copy>(f: F) {
|
2021-06-21 21:07:19 -05:00
|
|
|
| ++++++
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error: aborting due to 3 previous errors
|
|
|
|
|
2019-04-17 12:26:38 -05:00
|
|
|
Some errors have detailed explanations: E0382, E0502, E0596.
|
2018-08-08 07:28:26 -05:00
|
|
|
For more information about an error, try `rustc --explain E0382`.
|