diff options
| author | Nathan Kleyn <nathan@nathankleyn.com> | 2015-08-12 20:46:38 +0100 |
|---|---|---|
| committer | Nathan Kleyn <nathan@nathankleyn.com> | 2015-08-13 10:17:56 +0100 |
| commit | 55752a4bdeae5dad77875b7702a14882fd12725b (patch) | |
| tree | be6210f4ea5889b92c9f6d6c893e62ea79b203e3 | |
| parent | ea3cd022ef77d384cfef15460560f8cb86ac41e2 (diff) | |
Add detailed diagnostics for E0386.
This adds detailed diagnostics for E0386, 'cannot assign to data in an immutable container'.
| -rw-r--r-- | src/librustc_borrowck/diagnostics.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs index 850701e7046..1aa735f8c63 100644 --- a/src/librustc_borrowck/diagnostics.rs +++ b/src/librustc_borrowck/diagnostics.rs @@ -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: @@ -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 } |
