1 error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
2 --> $DIR/issue-39544.rs:11:13
4 LL | let z = Z { x: X::Y };
5 | - help: consider changing this to be mutable: `mut z`
7 | ^^^^^^^^ cannot borrow as mutable
9 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
10 --> $DIR/issue-39544.rs:16:17
12 LL | fn foo<'z>(&'z self) {
13 | -------- help: consider changing this to be a mutable reference: `&'z mut self`
14 LL | let _ = &mut self.x;
15 | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
17 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
18 --> $DIR/issue-39544.rs:20:17
20 LL | fn foo1(&self, other: &Z) {
21 | ----- help: consider changing this to be a mutable reference: `&mut self`
22 LL | let _ = &mut self.x;
23 | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
25 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
26 --> $DIR/issue-39544.rs:21:17
28 LL | fn foo1(&self, other: &Z) {
29 | -- help: consider changing this to be a mutable reference: `&mut Z`
30 LL | let _ = &mut self.x;
31 LL | let _ = &mut other.x;
32 | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
34 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
35 --> $DIR/issue-39544.rs:25:17
37 LL | fn foo2<'a>(&'a self, other: &Z) {
38 | -------- help: consider changing this to be a mutable reference: `&'a mut self`
39 LL | let _ = &mut self.x;
40 | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
42 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
43 --> $DIR/issue-39544.rs:26:17
45 LL | fn foo2<'a>(&'a self, other: &Z) {
46 | -- help: consider changing this to be a mutable reference: `&mut Z`
47 LL | let _ = &mut self.x;
48 LL | let _ = &mut other.x;
49 | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
51 error[E0596]: cannot borrow `self.x` as mutable, as it is behind a `&` reference
52 --> $DIR/issue-39544.rs:30:17
54 LL | fn foo3<'a>(self: &'a Self, other: &Z) {
55 | -------- help: consider changing this to be a mutable reference: `&'a mut Self`
56 LL | let _ = &mut self.x;
57 | ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable
59 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
60 --> $DIR/issue-39544.rs:31:17
62 LL | fn foo3<'a>(self: &'a Self, other: &Z) {
63 | -- help: consider changing this to be a mutable reference: `&mut Z`
64 LL | let _ = &mut self.x;
65 LL | let _ = &mut other.x;
66 | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
68 error[E0596]: cannot borrow `other.x` as mutable, as it is behind a `&` reference
69 --> $DIR/issue-39544.rs:35:17
71 LL | fn foo4(other: &Z) {
72 | -- help: consider changing this to be a mutable reference: `&mut Z`
73 LL | let _ = &mut other.x;
74 | ^^^^^^^^^^^^ `other` is a `&` reference, so the data it refers to cannot be borrowed as mutable
76 error[E0596]: cannot borrow `z.x` as mutable, as `z` is not declared as mutable
77 --> $DIR/issue-39544.rs:41:13
79 LL | pub fn with_arg(z: Z, w: &Z) {
80 | - help: consider changing this to be mutable: `mut z`
81 LL | let _ = &mut z.x;
82 | ^^^^^^^^ cannot borrow as mutable
84 error[E0596]: cannot borrow `w.x` as mutable, as it is behind a `&` reference
85 --> $DIR/issue-39544.rs:42:13
87 LL | pub fn with_arg(z: Z, w: &Z) {
88 | -- help: consider changing this to be a mutable reference: `&mut Z`
89 LL | let _ = &mut z.x;
90 LL | let _ = &mut w.x;
91 | ^^^^^^^^ `w` is a `&` reference, so the data it refers to cannot be borrowed as mutable
93 error[E0594]: cannot assign to `*x.0`, which is behind a `&` reference
94 --> $DIR/issue-39544.rs:48:5
97 | ^^^^^^^^ cannot assign
99 error: aborting due to 12 previous errors
101 Some errors have detailed explanations: E0594, E0596.
102 For more information about an error, try `rustc --explain E0594`.