rust/src/test/ui/borrowck/mutability-errors.stderr

309 lines
9.5 KiB
Text
Raw Normal View History

error[E0594]: cannot assign to immutable borrowed content `*x`
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:9:5
|
LL | fn named_ref(x: &(i32,)) {
| ------- use `&mut (i32,)` here to make mutable
LL | *x = (1,); //~ ERROR
| ^^^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to field `x.0` of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:10:5
|
LL | fn named_ref(x: &(i32,)) {
| ------- use `&mut (i32,)` here to make mutable
LL | *x = (1,); //~ ERROR
LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable borrowed content `*x` as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:11:10
|
LL | fn named_ref(x: &(i32,)) {
| ------- use `&mut (i32,)` here to make mutable
...
LL | &mut *x; //~ ERROR
| ^^ cannot borrow as mutable
error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:12:10
|
LL | fn named_ref(x: &(i32,)) {
| ------- use `&mut (i32,)` here to make mutable
...
LL | &mut x.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding
error[E0594]: cannot assign to immutable borrowed content
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:16:5
|
LL | *f() = (1,); //~ ERROR
| ^^^^^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to field of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:17:5
|
LL | f().0 = 1; //~ ERROR
| ^^^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable borrowed content as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:18:10
|
LL | &mut *f(); //~ ERROR
| ^^^^ cannot borrow as mutable
error[E0596]: cannot borrow field of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:19:10
|
LL | &mut f().0; //~ ERROR
| ^^^^^ cannot mutably borrow field of immutable binding
error[E0594]: cannot assign to immutable dereference of raw pointer `*x`
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:23:5
|
LL | *x = (1,); //~ ERROR
| ^^^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to field `x.0` of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:24:5
|
LL | (*x).0 = 1; //~ ERROR
| ^^^^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable dereference of raw pointer `*x` as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:25:10
|
LL | &mut *x; //~ ERROR
| ^^ cannot borrow as mutable
error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:26:10
|
LL | &mut (*x).0; //~ ERROR
| ^^^^^^ cannot mutably borrow field of immutable binding
error[E0594]: cannot assign to immutable dereference of raw pointer
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:30:5
|
LL | *f() = (1,); //~ ERROR
| ^^^^^^^^^^^ cannot borrow as mutable
error[E0594]: cannot assign to field of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:31:5
|
LL | (*f()).0 = 1; //~ ERROR
| ^^^^^^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable dereference of raw pointer as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:32:10
|
LL | &mut *f(); //~ ERROR
| ^^^^ cannot borrow as mutable
error[E0596]: cannot borrow field of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:33:10
|
LL | &mut (*f()).0; //~ ERROR
| ^^^^^^^^ cannot mutably borrow field of immutable binding
error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:40:9
|
LL | x = (1,); //~ ERROR
| ^^^^^^^^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:39:12
|
LL | fn_ref(|| {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0387]: cannot assign to data in a captured outer variable in an `Fn` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:41:9
|
LL | x.0 = 1; //~ ERROR
| ^^^^^^^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:39:12
|
LL | fn_ref(|| {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:42:14
|
LL | &mut x; //~ ERROR
| ^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:39:12
|
LL | fn_ref(|| {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0387]: cannot borrow data mutably in a captured outer variable in an `Fn` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:43:14
|
LL | &mut x.0; //~ ERROR
| ^^^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:39:12
|
LL | fn_ref(|| {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:46:9
|
LL | x = (1,); //~ ERROR
| ^^^^^^^^
|
= note: `Fn` closures cannot capture their enclosing environment for modifications
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:45:12
|
LL | fn_ref(move || {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0594]: cannot assign to field `x.0` of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:47:9
|
LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow captured outer variable in an `Fn` closure as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:48:14
|
LL | &mut x; //~ ERROR
| ^
|
help: consider changing this closure to take self by mutable reference
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:45:12
|
LL | fn_ref(move || {
| ____________^
LL | | x = (1,); //~ ERROR
LL | | x.0 = 1; //~ ERROR
LL | | &mut x; //~ ERROR
LL | | &mut x.0; //~ ERROR
LL | | });
| |_____^
error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:49:14
|
LL | &mut x.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable argument `x` as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:54:10
|
LL | fn imm_local(x: (i32,)) {
| - help: make this binding mutable: `mut x`
LL | &mut x; //~ ERROR
| ^ cannot borrow mutably
error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:55:10
|
LL | fn imm_local(x: (i32,)) {
| - help: make this binding mutable: `mut x`
LL | &mut x; //~ ERROR
LL | &mut x.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding
error[E0595]: closure cannot assign to immutable argument `x`
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:59:5
|
LL | fn imm_capture(x: (i32,)) {
| - help: make this binding mutable: `mut x`
LL | || { //~ ERROR
| ^^ cannot borrow mutably
error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:66:9
|
LL | fn imm_capture(x: (i32,)) {
| - help: consider making `x` mutable: `mut x`
...
LL | x = (1,); //~ ERROR
| ^^^^^^^^
error[E0594]: cannot assign to field `x.0` of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:67:9
|
LL | x.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow captured outer variable in an `FnMut` closure as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:68:14
|
LL | &mut x; //~ ERROR
| ^
error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:69:14
|
LL | &mut x.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding
error[E0594]: cannot assign to immutable static item
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:76:5
|
LL | X = (1,); //~ ERROR
| ^^^^^^^^
error[E0594]: cannot assign to field of immutable binding
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:77:5
|
LL | X.0 = 1; //~ ERROR
| ^^^^^^^ cannot mutably borrow field of immutable binding
error[E0596]: cannot borrow immutable static item as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:78:10
|
LL | &mut X; //~ ERROR
| ^
error[E0596]: cannot borrow field of immutable binding as mutable
2018-12-25 08:56:47 -07:00
--> $DIR/mutability-errors.rs:79:10
|
LL | &mut X.0; //~ ERROR
| ^^^ cannot mutably borrow field of immutable binding
error: aborting due to 35 previous errors
Some errors occurred: E0387, E0594, E0595, E0596.
For more information about an error, try `rustc --explain E0387`.