fork/rust
git clone https://git.julia.blue/fork/rust
49cae55760d
1.44.0
1error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure 2 --> $DIR/borrow-immutable-upvar-mutation.rs:21:27 3 | 4LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 5 | - change this to accept `FnMut` instead of `Fn` 6... 7LL | let _f = to_fn(|| x = 42); 8 | ----- ^^^^^^ cannot assign 9 | | 10 | expects `Fn` instead of `FnMut` 11 12error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure 13 --> $DIR/borrow-immutable-upvar-mutation.rs:24:31 14 | 15LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 16 | - change this to accept `FnMut` instead of `Fn` 17... 18LL | let _g = to_fn(|| set(&mut y)); 19 | ----- ^^^^^^ cannot borrow as mutable 20 | | 21 | expects `Fn` instead of `FnMut` 22 23error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure 24 --> $DIR/borrow-immutable-upvar-mutation.rs:29:22 25 | 26LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 27 | - change this to accept `FnMut` instead of `Fn` 28... 29LL | to_fn(|| z = 42); 30 | ----- ^^^^^^ cannot assign 31 | | 32 | expects `Fn` instead of `FnMut` 33 34error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure 35 --> $DIR/borrow-immutable-upvar-mutation.rs:36:32 36 | 37LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 38 | - change this to accept `FnMut` instead of `Fn` 39... 40LL | let _f = to_fn(move || x = 42); 41 | ----- ^^^^^^ cannot assign 42 | | 43 | expects `Fn` instead of `FnMut` 44 45error[E0596]: cannot borrow `y` as mutable, as it is a captured variable in a `Fn` closure 46 --> $DIR/borrow-immutable-upvar-mutation.rs:39:36 47 | 48LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 49 | - change this to accept `FnMut` instead of `Fn` 50... 51LL | let _g = to_fn(move || set(&mut y)); 52 | ----- ^^^^^^ cannot borrow as mutable 53 | | 54 | expects `Fn` instead of `FnMut` 55 56error[E0594]: cannot assign to `z`, as it is a captured variable in a `Fn` closure 57 --> $DIR/borrow-immutable-upvar-mutation.rs:44:27 58 | 59LL | fn to_fn<A, F: Fn<A>>(f: F) -> F { 60 | - change this to accept `FnMut` instead of `Fn` 61... 62LL | to_fn(move || z = 42); 63 | ----- ^^^^^^ cannot assign 64 | | 65 | expects `Fn` instead of `FnMut` 66 67error[E0594]: cannot assign to `x`, as it is a captured variable in a `Fn` closure 68 --> $DIR/borrow-immutable-upvar-mutation.rs:53:9 69 | 70LL | fn foo() -> Box<dyn Fn() -> usize> { 71 | --- ---------------------- change this to return `FnMut` instead of `Fn` 72LL | let mut x = 0; 73LL | Box::new(move || { 74 | ______________- 75LL | | x += 1; 76 | | ^^^^^^ cannot assign 77LL | | x 78LL | | }) 79 | |_____- in this closure 80 81error: aborting due to 7 previous errors 82 83Some errors have detailed explanations: E0594, E0596. 84For more information about an error, try `rustc --explain E0594`.