File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,36 @@ fn main(){
181181```
182182"## ,
183183
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+
184214E0387 : r##"
185215This error occurs when an attempt is made to mutate or mutably reference data
186216that a closure has captured immutably. Examples of this error are shown below:
@@ -239,7 +269,6 @@ https://doc.rust-lang.org/std/cell/
239269
240270register_diagnostics ! {
241271 E0385 , // {} in an aliasable location
242- E0386 , // {} in an immutable container
243272 E0388 , // {} in a static location
244273 E0389 // {} in a `&` reference
245274}
You can’t perform that action at this time.
0 commit comments