about summary refs log tree commit diff
path: root/src/test/ui/borrowck/mutability-errors.stderr
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/borrowck/mutability-errors.stderr')
-rw-r--r--src/test/ui/borrowck/mutability-errors.stderr308
1 files changed, 308 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/mutability-errors.stderr b/src/test/ui/borrowck/mutability-errors.stderr
new file mode 100644
index 00000000000..d77254f3141
--- /dev/null
+++ b/src/test/ui/borrowck/mutability-errors.stderr
@@ -0,0 +1,308 @@
+error[E0594]: cannot assign to immutable borrowed content `*x`
+  --> $DIR/mutability-errors.rs:19: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
+  --> $DIR/mutability-errors.rs:20: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
+  --> $DIR/mutability-errors.rs:21: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
+  --> $DIR/mutability-errors.rs:22: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
+  --> $DIR/mutability-errors.rs:26:5
+   |
+LL |     *f() = (1,); //~ ERROR
+   |     ^^^^^^^^^^^ cannot borrow as mutable
+
+error[E0594]: cannot assign to field of immutable binding
+  --> $DIR/mutability-errors.rs:27:5
+   |
+LL |     f().0 = 1; //~ ERROR
+   |     ^^^^^^^^^ cannot mutably borrow field of immutable binding
+
+error[E0596]: cannot borrow immutable borrowed content as mutable
+  --> $DIR/mutability-errors.rs:28:10
+   |
+LL |     &mut *f(); //~ ERROR
+   |          ^^^^ cannot borrow as mutable
+
+error[E0596]: cannot borrow field of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:29:10
+   |
+LL |     &mut f().0; //~ ERROR
+   |          ^^^^^ cannot mutably borrow field of immutable binding
+
+error[E0594]: cannot assign to immutable dereference of raw pointer `*x`
+  --> $DIR/mutability-errors.rs:33:5
+   |
+LL |     *x = (1,); //~ ERROR
+   |     ^^^^^^^^^ cannot borrow as mutable
+
+error[E0594]: cannot assign to field `x.0` of immutable binding
+  --> $DIR/mutability-errors.rs:34: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
+  --> $DIR/mutability-errors.rs:35:10
+   |
+LL |     &mut *x; //~ ERROR
+   |          ^^ cannot borrow as mutable
+
+error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:36:10
+   |
+LL |     &mut (*x).0; //~ ERROR
+   |          ^^^^^^ cannot mutably borrow field of immutable binding
+
+error[E0594]: cannot assign to immutable dereference of raw pointer
+  --> $DIR/mutability-errors.rs:40:5
+   |
+LL |     *f() = (1,); //~ ERROR
+   |     ^^^^^^^^^^^ cannot borrow as mutable
+
+error[E0594]: cannot assign to field of immutable binding
+  --> $DIR/mutability-errors.rs:41:5
+   |
+LL |     (*f()).0 = 1; //~ ERROR
+   |     ^^^^^^^^^^^^ cannot mutably borrow field of immutable binding
+
+error[E0596]: cannot borrow immutable dereference of raw pointer as mutable
+  --> $DIR/mutability-errors.rs:42:10
+   |
+LL |     &mut *f(); //~ ERROR
+   |          ^^^^ cannot borrow as mutable
+
+error[E0596]: cannot borrow field of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:43: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
+  --> $DIR/mutability-errors.rs:50:9
+   |
+LL |         x = (1,); //~ ERROR
+   |         ^^^^^^^^
+   |
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/mutability-errors.rs:49: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
+  --> $DIR/mutability-errors.rs:51:9
+   |
+LL |         x.0 = 1; //~ ERROR
+   |         ^^^^^^^
+   |
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/mutability-errors.rs:49: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
+  --> $DIR/mutability-errors.rs:52:14
+   |
+LL |         &mut x; //~ ERROR
+   |              ^
+   |
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/mutability-errors.rs:49: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
+  --> $DIR/mutability-errors.rs:53:14
+   |
+LL |         &mut x.0; //~ ERROR
+   |              ^^^
+   |
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/mutability-errors.rs:49: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
+  --> $DIR/mutability-errors.rs:56: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
+  --> $DIR/mutability-errors.rs:55: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
+  --> $DIR/mutability-errors.rs:57: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
+  --> $DIR/mutability-errors.rs:58:14
+   |
+LL |         &mut x; //~ ERROR
+   |              ^
+   |
+help: consider changing this closure to take self by mutable reference
+  --> $DIR/mutability-errors.rs:55: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
+  --> $DIR/mutability-errors.rs:59:14
+   |
+LL |         &mut x.0; //~ ERROR
+   |              ^^^ cannot mutably borrow field of immutable binding
+
+error[E0596]: cannot borrow immutable argument `x` as mutable
+  --> $DIR/mutability-errors.rs:64:10
+   |
+LL | fn imm_local(x: (i32,)) {
+   |              - consider changing this to `mut x`
+LL |     &mut x; //~ ERROR
+   |          ^ cannot borrow mutably
+
+error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:65:10
+   |
+LL | fn imm_local(x: (i32,)) {
+   |              - consider changing this to `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`
+  --> $DIR/mutability-errors.rs:69:5
+   |
+LL | fn imm_capture(x: (i32,)) {
+   |                - consider changing this to `mut x`
+LL |     || { //~ ERROR
+   |     ^^ cannot borrow mutably
+
+error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
+  --> $DIR/mutability-errors.rs:76: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
+  --> $DIR/mutability-errors.rs:77: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
+  --> $DIR/mutability-errors.rs:78:14
+   |
+LL |         &mut x; //~ ERROR
+   |              ^
+
+error[E0596]: cannot borrow field `x.0` of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:79:14
+   |
+LL |         &mut x.0; //~ ERROR
+   |              ^^^ cannot mutably borrow field of immutable binding
+
+error[E0594]: cannot assign to immutable static item
+  --> $DIR/mutability-errors.rs:86:5
+   |
+LL |     X = (1,); //~ ERROR
+   |     ^^^^^^^^
+
+error[E0594]: cannot assign to field of immutable binding
+  --> $DIR/mutability-errors.rs:87:5
+   |
+LL |     X.0 = 1; //~ ERROR
+   |     ^^^^^^^ cannot mutably borrow field of immutable binding
+
+error[E0596]: cannot borrow immutable static item as mutable
+  --> $DIR/mutability-errors.rs:88:10
+   |
+LL |     &mut X; //~ ERROR
+   |          ^
+
+error[E0596]: cannot borrow field of immutable binding as mutable
+  --> $DIR/mutability-errors.rs:89: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`.