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

79 lines
3.5 KiB
Plaintext
Raw Normal View History

2018-08-08 07:28:26 -05:00
error[E0387]: cannot assign to data in a captured outer variable in an `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 | let _f = to_fn(|| x = 42); //~ ERROR cannot assign
| ^^^^^^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:15:24
2018-08-08 07:28:26 -05:00
|
LL | let _f = to_fn(|| x = 42); //~ ERROR cannot assign
| ^^^^^^^^^
error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:18:36
2018-08-08 07:28:26 -05:00
|
LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
| ^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:18:24
2018-08-08 07:28:26 -05:00
|
LL | let _g = to_fn(|| set(&mut y)); //~ ERROR cannot borrow
| ^^^^^^^^^^^^^^
error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:21:55
2018-08-08 07:28:26 -05:00
|
LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
| ^^^^^^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:21:52
2018-08-08 07:28:26 -05:00
|
LL | let _h = to_fn_mut(|| { set(&mut z); to_fn(|| z = 42); }); //~ ERROR cannot assign
| ^^^^^^^^^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:27:32
2018-08-08 07:28:26 -05:00
|
LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:27:24
2018-08-08 07:28:26 -05:00
|
LL | let _f = to_fn(move || x = 42); //~ ERROR cannot assign
| ^^^^^^^^^^^^^^
error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:30:41
2018-08-08 07:28:26 -05:00
|
LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
| ^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:30:24
2018-08-08 07:28:26 -05:00
|
LL | let _g = to_fn(move || set(&mut y)); //~ ERROR cannot borrow
| ^^^^^^^^^^^^^^^^^^^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:33:65
2018-08-08 07:28:26 -05:00
|
LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
| ^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
2018-12-25 09:56:47 -06:00
--> $DIR/borrow-immutable-upvar-mutation.rs:33:57
2018-08-08 07:28:26 -05:00
|
LL | let _h = to_fn_mut(move || { set(&mut z); to_fn(move || z = 42); }); //~ ERROR cannot assign
| ^^^^^^^^^^^^^^
error: aborting due to 6 previous errors
Some errors occurred: E0387, E0594, E0596.
For more information about an error, try `rustc --explain E0387`.