Skip to content

Commit

Permalink
Add detailed diagnostics for E0386.
Browse files Browse the repository at this point in the history
This adds detailed diagnostics for E0386, 'cannot assign to data in an
immutable container'.
  • Loading branch information
nathankleyn committed Aug 13, 2015
1 parent ea3cd02 commit 55752a4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/librustc_borrowck/diagnostics.rs
Expand Up @@ -160,6 +160,27 @@ fn main(){
```
"##,

E0386: r##"
This error occurs when an attempt is made to mutate the target of a mutable
reference stored inside an immutable container.
For example, this can happen when storing a `&mut` inside an immutable `Box`:
```
let mut x: i64 = 1;
let y: Box<_> = Box::new(&mut x);
**y = 2; // error, cannot assign to data in an immutable container
```
This error can be fixed by making the container mutable:
```
let mut x: i64 = 1;
let mut y: Box<_> = Box::new(&mut x);
**y = 2;
```
"##,

E0387: r##"
This error occurs when an attempt is made to mutate or mutably reference data
that a closure has captured immutably. Examples of this error are shown below:
Expand Down Expand Up @@ -219,7 +240,6 @@ https://doc.rust-lang.org/std/cell/
register_diagnostics! {
E0383, // partial reinitialization of uninitialized structure
E0385, // {} in an aliasable location
E0386, // {} in an immutable container
E0388, // {} in a static location
E0389 // {} in a `&` reference
}

0 comments on commit 55752a4

Please sign in to comment.