1
- error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable
2
- --> $DIR/borrow-mut-xor-share.rs:24:17
3
- |
4
- LL | foo_pin_mut(&pin mut foo);
5
- | ^^^^^^^^^^^^ cannot borrow as mutable
6
- |
7
- help: consider changing this to be mutable
1
+ error[E0382]: borrow of moved value: `foo`
2
+ --> $DIR/borrow-mut-xor-share.rs:31:17
8
3
|
9
4
LL | let mut foo = Foo;
10
- | +++
11
-
12
- error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable
13
- --> $DIR/borrow-mut-xor-share.rs:28:17
14
- |
5
+ | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
15
6
LL | let x = &pin mut foo;
16
- | ------------ mutable borrow occurs here
7
+ | --- value moved here
17
8
LL | foo_pin_ref(&pin const foo);
18
- | ^^^^^^^^^^^^^^ immutable borrow occurs here
19
- ...
20
- LL | foo_pin_mut(x);
21
- | - mutable borrow later used here
22
-
23
- error[E0499]: cannot borrow `foo` as mutable more than once at a time
24
- --> $DIR/borrow-mut-xor-share.rs:29:17
9
+ | ^^^^^^^^^^^^^^ value borrowed here after move
25
10
|
26
- LL | let x = &pin mut foo;
27
- | ------------ first mutable borrow occurs here
28
- LL | foo_pin_ref(&pin const foo);
29
- LL | foo_pin_mut(&pin mut foo) ;
30
- | ^^^^^^^^^^^^ second mutable borrow occurs here
11
+ note: if `Foo` implemented `Clone`, you could clone the value
12
+ --> $DIR/borrow-mut-xor-share.rs:11:1
13
+ |
14
+ LL | struct Foo ;
15
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
31
16
...
32
- LL | foo_pin_mut(x) ;
33
- | - first borrow later used here
17
+ LL | let x = &pin mut foo ;
18
+ | --- you could clone this value
34
19
35
- error[E0502 ]: cannot borrow `foo` as immutable because it is also borrowed as mutable
36
- --> $DIR/borrow-mut-xor-share.rs:30 :13
20
+ error[E0382 ]: borrow of moved value: `foo`
21
+ --> $DIR/borrow-mut-xor-share.rs:33 :13
37
22
|
38
- LL | let x = &pin mut foo;
39
- | ------------ mutable borrow occurs here
23
+ LL | let mut foo = Foo ;
24
+ | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
40
25
...
26
+ LL | foo_pin_mut(&pin mut foo); // ok
27
+ | --- value moved here
41
28
LL | foo_ref(&foo);
42
- | ^^^^ immutable borrow occurs here
43
- ...
44
- LL | foo_pin_mut(x);
45
- | - mutable borrow later used here
46
-
47
- error[E0499]: cannot borrow `foo` as mutable more than once at a time
48
- --> $DIR/borrow-mut-xor-share.rs:31:13
29
+ | ^^^^ value borrowed here after move
49
30
|
50
- LL | let x = &pin mut foo;
51
- | ------------ first mutable borrow occurs here
31
+ note: if `Foo` implemented `Clone`, you could clone the value
32
+ --> $DIR/borrow-mut-xor-share.rs:11:1
33
+ |
34
+ LL | struct Foo;
35
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
52
36
...
53
- LL | foo_mut(&mut foo);
54
- | ^^^^^^^^ second mutable borrow occurs here
55
- LL |
56
- LL | foo_pin_mut(x);
57
- | - first borrow later used here
37
+ LL | foo_pin_mut(&pin mut foo); // ok
38
+ | --- you could clone this value
58
39
59
- error[E0502 ]: cannot borrow `foo` as mutable because it is also borrowed as immutable
60
- --> $DIR/borrow-mut-xor-share.rs:38:17
40
+ error[E0505 ]: cannot move out of `foo` because it is borrowed
41
+ --> $DIR/borrow-mut-xor-share.rs:41:26
61
42
|
43
+ LL | let mut foo = Foo;
44
+ | ------- binding `foo` declared here
62
45
LL | let x = &pin const foo;
63
- | -------------- immutable borrow occurs here
46
+ | -------------- borrow of `foo` occurs here
64
47
LL | foo_pin_ref(&pin const foo); // ok
65
48
LL | foo_pin_mut(&pin mut foo);
66
- | ^^^^^^^^^^^^ mutable borrow occurs here
49
+ | ^^^ move out of `foo` occurs here
67
50
...
68
51
LL | foo_pin_ref(x);
69
- | - immutable borrow later used here
52
+ | - borrow later used here
53
+ |
54
+ note: if `Foo` implemented `Clone`, you could clone the value
55
+ --> $DIR/borrow-mut-xor-share.rs:11:1
56
+ |
57
+ LL | struct Foo;
58
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
59
+ ...
60
+ LL | let x = &pin const foo;
61
+ | --- you could clone this value
62
+
63
+ error[E0382]: borrow of moved value: `foo`
64
+ --> $DIR/borrow-mut-xor-share.rs:42:13
65
+ |
66
+ LL | let mut foo = Foo;
67
+ | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
68
+ ...
69
+ LL | foo_pin_mut(&pin mut foo);
70
+ | --- value moved here
71
+ LL | foo_ref(&foo);
72
+ | ^^^^ value borrowed here after move
73
+ |
74
+ note: if `Foo` implemented `Clone`, you could clone the value
75
+ --> $DIR/borrow-mut-xor-share.rs:11:1
76
+ |
77
+ LL | struct Foo;
78
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
79
+ ...
80
+ LL | foo_pin_mut(&pin mut foo);
81
+ | --- you could clone this value
70
82
71
83
error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable
72
- --> $DIR/borrow-mut-xor-share.rs:40 :13
84
+ --> $DIR/borrow-mut-xor-share.rs:43 :13
73
85
|
74
86
LL | let x = &pin const foo;
75
87
| -------------- immutable borrow occurs here
@@ -81,7 +93,7 @@ LL | foo_pin_ref(x);
81
93
| - immutable borrow later used here
82
94
83
95
error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable
84
- --> $DIR/borrow-mut-xor-share.rs:46 :17
96
+ --> $DIR/borrow-mut-xor-share.rs:49 :17
85
97
|
86
98
LL | let x = &mut foo;
87
99
| -------- mutable borrow occurs here
@@ -91,31 +103,53 @@ LL | foo_pin_ref(&pin const foo);
91
103
LL | foo_mut(x);
92
104
| - mutable borrow later used here
93
105
94
- error[E0499 ]: cannot borrow `foo` as mutable more than once at a time
95
- --> $DIR/borrow-mut-xor-share.rs:47:17
106
+ error[E0505 ]: cannot move out of `foo` because it is borrowed
107
+ --> $DIR/borrow-mut-xor-share.rs:50:26
96
108
|
109
+ LL | let mut foo = Foo;
110
+ | ------- binding `foo` declared here
97
111
LL | let x = &mut foo;
98
- | -------- first mutable borrow occurs here
112
+ | -------- borrow of `foo` occurs here
99
113
LL | foo_pin_ref(&pin const foo);
100
114
LL | foo_pin_mut(&pin mut foo);
101
- | ^^^^^^^^^^^^ second mutable borrow occurs here
115
+ | ^^^ move out of `foo` occurs here
102
116
LL |
103
117
LL | foo_mut(x);
104
- | - first borrow later used here
118
+ | - borrow later used here
119
+ |
120
+ note: if `Foo` implemented `Clone`, you could clone the value
121
+ --> $DIR/borrow-mut-xor-share.rs:11:1
122
+ |
123
+ LL | struct Foo;
124
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
125
+ ...
126
+ LL | let x = &mut foo;
127
+ | --- you could clone this value
105
128
106
- error[E0502 ]: cannot borrow `foo` as mutable because it is also borrowed as immutable
107
- --> $DIR/borrow-mut-xor-share.rs:54:17
129
+ error[E0505 ]: cannot move out of `foo` because it is borrowed
130
+ --> $DIR/borrow-mut-xor-share.rs:57:26
108
131
|
132
+ LL | let mut foo = Foo;
133
+ | ------- binding `foo` declared here
109
134
LL | let x = &foo;
110
- | ---- immutable borrow occurs here
135
+ | ---- borrow of `foo` occurs here
111
136
LL | foo_pin_ref(&pin const foo); // ok
112
137
LL | foo_pin_mut(&pin mut foo);
113
- | ^^^^^^^^^^^^ mutable borrow occurs here
138
+ | ^^^ move out of `foo` occurs here
114
139
LL |
115
140
LL | foo_ref(x);
116
- | - immutable borrow later used here
141
+ | - borrow later used here
142
+ |
143
+ note: if `Foo` implemented `Clone`, you could clone the value
144
+ --> $DIR/borrow-mut-xor-share.rs:11:1
145
+ |
146
+ LL | struct Foo;
147
+ | ^^^^^^^^^^ consider implementing `Clone` for this type
148
+ ...
149
+ LL | let x = &foo;
150
+ | --- you could clone this value
117
151
118
- error: aborting due to 10 previous errors
152
+ error: aborting due to 8 previous errors
119
153
120
- Some errors have detailed explanations: E0499 , E0502, E0596 .
121
- For more information about an error, try `rustc --explain E0499 `.
154
+ Some errors have detailed explanations: E0382 , E0502, E0505 .
155
+ For more information about an error, try `rustc --explain E0382 `.
0 commit comments