diff options
| author | Nathan Kleyn <nathan@nathankleyn.com> | 2015-08-12 18:07:56 +0100 |
|---|---|---|
| committer | Nathan Kleyn <nathan@nathankleyn.com> | 2015-08-13 09:06:29 +0100 |
| commit | 9c0d2b246589d7329d78e93afc04d270278e6ada (patch) | |
| tree | fb4255d430b27a236db9c535c515c168fcfd5872 | |
| parent | 8b5948d5bf08f27bf443356549a25b39d40c159d (diff) | |
| download | rust-9c0d2b246589d7329d78e93afc04d270278e6ada.tar.gz rust-9c0d2b246589d7329d78e93afc04d270278e6ada.zip | |
Add detailed diagnostics for E0383.
This adds detailed diagnostics for E0383, 'partial reinitialization of uninitialized structure'. This is part of rust-lang/rust#24407.
| -rw-r--r-- | src/librustc_borrowck/diagnostics.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs index 850701e7046..acd2bf3fba9 100644 --- a/src/librustc_borrowck/diagnostics.rs +++ b/src/librustc_borrowck/diagnostics.rs @@ -138,6 +138,30 @@ Book: https://doc.rust-lang.org/book/ownership.html "##, +E0383: r##" +This error occurs when an attempt is made to partially reinitialize a +structure that is currently uninitialized. + +For example, this can happen when a transfer of ownership has taken place: + +``` +let mut t = Test { a: 1, b: None}; +let mut u = Test { a: 2, b: Some(Box::new(t))}; // `t` is now uninitialized + // because ownership has been + // transferred +t.b = Some(Box::new(u)); // error, partial reinitialization of uninitialized + // structure `t` +``` + +This error can be fixed by fully reinitializing the structure in question: + +``` +let mut t = Test { a: 1, b: None}; +let mut u = Test { a: 2, b: Some(Box::new(t))}; +t = Test { a: 1, b: Some(Box::new(u))}; +``` +"##, + E0384: r##" This error occurs when an attempt is made to reassign an immutable variable. For example: @@ -217,7 +241,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 |
