rust/src/test/ui/borrowck/borrow-immutable-upvar-mutation.stderr

98 lines
3.8 KiB
Plaintext
Raw Normal View History

error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:15:27
2018-08-08 07:28:26 -05:00
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
2019-03-09 06:03:44 -06:00
LL | let _f = to_fn(|| x = 42);
| ----- ^^^^^^ cannot assign
| |
| expects `Fn` instead of `FnMut`
2018-08-08 07:28:26 -05:00
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:18:31
2018-08-08 07:28:26 -05:00
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
2019-03-09 06:03:44 -06:00
LL | let _g = to_fn(|| set(&mut y));
| ----- ^^^^^^ cannot borrow as mutable
| |
| expects `Fn` instead of `FnMut`
2018-08-08 07:28:26 -05:00
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:23:22
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
LL | to_fn(|| z = 42);
| ----- ^^^^^^ cannot assign
| |
| expects `Fn` instead of `FnMut`
2018-08-08 07:28:26 -05:00
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:30:32
2018-08-08 07:28:26 -05:00
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
2019-03-09 06:03:44 -06:00
LL | let _f = to_fn(move || x = 42);
| ----- ^^^^^^ cannot assign
| |
| expects `Fn` instead of `FnMut`
2018-08-08 07:28:26 -05:00
error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:33:36
2018-08-08 07:28:26 -05:00
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
2019-03-09 06:03:44 -06:00
LL | let _g = to_fn(move || set(&mut y));
| ----- ^^^^^^ cannot borrow as mutable
| |
| expects `Fn` instead of `FnMut`
2018-08-08 07:28:26 -05:00
error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:36:65
2018-08-08 07:28:26 -05:00
|
LL | fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
| - change this to accept `FnMut` instead of `Fn`
...
2019-03-09 06:03:44 -06:00
LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); });
| ----- ^^^^^^ cannot assign
| |
| expects `Fn` instead of `FnMut`
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:43:9
|
LL | fn foo() -> Box<dyn Fn() -> usize> {
2020-02-08 23:05:43 -06:00
| --- ---------------------- change this to return `FnMut` instead of `Fn`
LL | let mut x = 0;
LL | Box::new(move || {
| ______________-
LL | | x += 1;
| | ^^^^^^ cannot assign
LL | | x
LL | | })
| |_____- in this closure
error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure
--> $DIR/borrow-immutable-upvar-mutation.rs:51:9
|
LL | fn bar() -> impl Fn() -> usize {
2020-02-08 23:05:43 -06:00
| --- ------------------ change this to return `FnMut` instead of `Fn`
LL | let mut x = 0;
LL | / move || {
LL | | x += 1;
| | ^^^^^^ cannot assign
LL | | x
LL | | }
| |_____- in this closure
2018-08-08 07:28:26 -05:00
error: aborting due to 8 previous errors
2018-08-08 07:28:26 -05:00
2019-11-06 06:58:44 -06:00
Some errors have detailed explanations: E0594, E0596.
For more information about an error, try `rustc --explain E0594`.