rust/src/test/ui/borrowck/borrowck-unboxed-closures.stderr

35 lines
1.3 KiB
Plaintext
Raw Normal View History

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;
| ------ 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
LL | use_mut(g);
| - mutable borrow later used here
2018-08-08 07:28:26 -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
|
LL | fn b<F:FnMut(isize, isize) -> isize>(f: F) {
| - help: consider changing this to be mutable: `mut f`
2019-03-09 06:03:44 -06:00
LL | f(1, 2);
| ^ cannot borrow as mutable
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
|
LL | fn c<F:FnOnce(isize, isize) -> isize>(f: F) {
| -- - move occurs because `f` has type `F`, which does not implement the `Copy` trait
| |
| help: consider further restricting this bound: `F: Copy +`
2018-08-08 07:28:26 -05:00
LL | f(1, 2);
| - value moved here
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
error: aborting due to 3 previous errors
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`.