2019-04-22 07:40:08 +00:00
|
|
|
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:21:27
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _f = to_fn(|| x = 42);
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- -- ^^^^^^ cannot assign
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-04 00:08:45 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:24:31
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _g = to_fn(|| set(&mut y));
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- -- ^^^^^^ cannot borrow as mutable
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-04 00:08:45 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:29:22
|
2020-02-04 00:08:45 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
|
|
|
LL | to_fn(|| z = 42);
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- -- ^^^^^^ cannot assign
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-04 00:08:45 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:36:32
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _f = to_fn(move || x = 42);
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- ------- ^^^^^^ cannot assign
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-04 00:08:45 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:39:36
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
2019-03-09 12:03:44 +00:00
|
|
|
LL | let _g = to_fn(move || set(&mut y));
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- ------- ^^^^^^ cannot borrow as mutable
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-04 00:08:45 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-04-22 07:40:08 +00:00
|
|
|
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:44:27
|
2018-08-08 12:28:26 +00:00
|
|
|
|
|
2022-07-30 05:37:48 +00:00
|
|
|
LL | fn to_fn<A: std::marker::Tuple, F: Fn<A>>(f: F) -> F {
|
|
|
|
| - change this to accept `FnMut` instead of `Fn`
|
2020-02-04 00:08:45 +00:00
|
|
|
...
|
2020-02-14 22:39:55 +00:00
|
|
|
LL | to_fn(move || z = 42);
|
2022-06-27 05:33:19 +00:00
|
|
|
| ----- ------- ^^^^^^ cannot assign
|
|
|
|
| | |
|
|
|
|
| | in this closure
|
2020-02-14 22:39:55 +00:00
|
|
|
| expects `Fn` instead of `FnMut`
|
2020-02-04 00:08:45 +00:00
|
|
|
|
|
|
|
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
|
2020-02-14 22:39:55 +00:00
|
|
|
--> $DIR/borrow-immutable-upvar-mutation.rs:53:9
|
2020-02-04 00:08:45 +00:00
|
|
|
|
|
2022-06-27 05:45:35 +00:00
|
|
|
LL | fn foo() -> Box<dyn Fn() -> usize> {
|
|
|
|
| --- ---------------------- change this to return `FnMut` instead of `Fn`
|
|
|
|
LL | let mut x = 0;
|
|
|
|
LL | Box::new(move || {
|
|
|
|
| ------- in this closure
|
|
|
|
LL | x += 1;
|
|
|
|
| ^^^^^^ cannot assign
|
2020-02-04 00:08:45 +00:00
|
|
|
|
2020-02-14 22:39:55 +00:00
|
|
|
error: aborting due to 7 previous errors
|
2018-08-08 12:28:26 +00:00
|
|
|
|
2019-11-06 12:58:44 +00:00
|
|
|
Some errors have detailed explanations: E0594, E0596.
|
|
|
|
For more information about an error, try `rustc --explain E0594`.
|