2016-11-08 09:21:53 +03:00
|
|
|
error[E0499]: cannot borrow `f` as mutable more than once at a time
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:12:16
|
2016-11-08 09:21:53 +03:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | f(Box::new(|| {
|
2016-11-08 09:21:53 +03:00
|
|
|
| - ^^ second mutable borrow occurs here
|
|
|
|
| |
|
|
|
|
| first mutable borrow occurs here
|
2019-04-22 08:40:08 +01:00
|
|
|
| first borrow later used by call
|
2019-03-09 15:03:44 +03:00
|
|
|
LL |
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | f((Box::new(|| {})))
|
2019-04-22 08:40:08 +01:00
|
|
|
| - second borrow occurs due to use of `f` in closure
|
2016-11-08 09:21:53 +03:00
|
|
|
|
2019-04-22 08:40:08 +01:00
|
|
|
error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:25:5
|
2016-11-08 09:21:53 +03:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | (*f)();
|
2019-04-22 08:40:08 +01:00
|
|
|
| ^^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
2022-12-28 21:52:57 -08:00
|
|
|
|
|
|
|
|
help: consider changing this to be a mutable reference
|
|
|
|
|
|
|
|
|
LL | fn test2<F>(f: &mut F) where F: FnMut() {
|
2023-04-19 19:50:08 +12:00
|
|
|
| +++
|
2016-11-08 09:21:53 +03:00
|
|
|
|
2019-04-22 08:40:08 +01:00
|
|
|
error[E0596]: cannot borrow `f.f` as mutable, as it is behind a `&` reference
|
2018-12-25 08:56:47 -07:00
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:34:5
|
2016-11-08 09:21:53 +03:00
|
|
|
|
|
2018-02-23 03:42:32 +03:00
|
|
|
LL | f.f.call_mut(())
|
2023-06-22 20:30:23 +00:00
|
|
|
| ^^^ `f` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
2022-12-28 21:52:57 -08:00
|
|
|
|
|
|
|
|
help: consider changing this to be a mutable reference
|
|
|
|
|
|
2023-04-19 19:50:08 +12:00
|
|
|
LL | fn test4(f: &mut Test) {
|
|
|
|
| +++
|
2016-11-08 09:21:53 +03:00
|
|
|
|
2019-05-05 12:02:32 +01:00
|
|
|
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
|
2019-04-22 08:40:08 +01:00
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
|
2016-11-08 09:21:53 +03:00
|
|
|
|
|
2022-06-27 07:45:35 +02:00
|
|
|
LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
|
|
|
|
| ----- captured outer variable
|
2018-03-23 10:57:28 +01:00
|
|
|
...
|
2022-06-27 07:45:35 +02:00
|
|
|
LL | f(Box::new(|a| {
|
|
|
|
| --- captured by this `FnMut` closure
|
|
|
|
LL |
|
|
|
|
LL | foo(f);
|
2023-09-09 08:36:50 +02:00
|
|
|
| ^ 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
|
2019-04-22 08:40:08 +01:00
|
|
|
|
|
|
|
error[E0505]: cannot move out of `f` because it is borrowed
|
|
|
|
--> $DIR/borrowck-call-is-borrow-issue-12224.rs:55:16
|
|
|
|
|
|
2023-01-15 03:06:44 +00:00
|
|
|
LL | let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
|
|
|
|
| ----- binding `f` declared here
|
|
|
|
...
|
2019-04-22 08:40:08 +01:00
|
|
|
LL | f(Box::new(|a| {
|
|
|
|
| - ^^^ move out of `f` occurs here
|
|
|
|
| |
|
|
|
|
| borrow of `f` occurs here
|
|
|
|
LL |
|
|
|
|
LL | foo(f);
|
|
|
|
| - move occurs due to use in closure
|
2016-11-08 09:21:53 +03:00
|
|
|
|
2017-07-02 13:49:30 +03:00
|
|
|
error: aborting due to 5 previous errors
|
2016-11-08 09:21:53 +03:00
|
|
|
|
2019-04-22 08:40:08 +01:00
|
|
|
Some errors have detailed explanations: E0499, E0505, E0507, E0596.
|
2018-03-03 15:59:40 +01:00
|
|
|
For more information about an error, try `rustc --explain E0499`.
|