File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,36 @@ fn main(){
181
181
```
182
182
"## ,
183
183
184
+ E0386 : r##"
185
+ This error occurs when an attempt is made to mutate the target of a mutable
186
+ reference stored inside an immutable container.
187
+
188
+ For example, this can happen when storing a `&mut` inside an immutable `Box`:
189
+
190
+ ```
191
+ let mut x: i64 = 1;
192
+ let y: Box<_> = Box::new(&mut x);
193
+ **y = 2; // error, cannot assign to data in an immutable container
194
+ ```
195
+
196
+ This error can be fixed by making the container mutable:
197
+
198
+ ```
199
+ let mut x: i64 = 1;
200
+ let mut y: Box<_> = Box::new(&mut x);
201
+ **y = 2;
202
+ ```
203
+
204
+ It can also be fixed by using a type with interior mutability, such as `Cell` or
205
+ `RefCell`:
206
+
207
+ ```
208
+ let x: i64 = 1;
209
+ let y: Box<Cell<_>> = Box::new(Cell::new(x));
210
+ y.set(2);
211
+ ```
212
+ "## ,
213
+
184
214
E0387 : r##"
185
215
This error occurs when an attempt is made to mutate or mutably reference data
186
216
that a closure has captured immutably. Examples of this error are shown below:
@@ -239,7 +269,6 @@ https://doc.rust-lang.org/std/cell/
239
269
240
270
register_diagnostics ! {
241
271
E0385 , // {} in an aliasable location
242
- E0386 , // {} in an immutable container
243
272
E0388 , // {} in a static location
244
273
E0389 // {} in a `&` reference
245
274
}
You can’t perform that action at this time.
0 commit comments