about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathan Kleyn <nathan@nathankleyn.com>2015-08-13 09:11:06 +0100
committerNathan Kleyn <nathan@nathankleyn.com>2015-08-13 09:11:06 +0100
commit67c7fd710be56cf3ba5ca03b7291add856e73a8d (patch)
tree0e36afeee8c6a219084844c459d31f8ef2bb3b98
parent9c0d2b246589d7329d78e93afc04d270278e6ada (diff)
downloadrust-67c7fd710be56cf3ba5ca03b7291add856e73a8d.tar.gz
rust-67c7fd710be56cf3ba5ca03b7291add856e73a8d.zip
Improve code examples for E0383 long diagnostic.
-rw-r--r--src/librustc_borrowck/diagnostics.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/librustc_borrowck/diagnostics.rs b/src/librustc_borrowck/diagnostics.rs
index acd2bf3fba9..0bc43952926 100644
--- a/src/librustc_borrowck/diagnostics.rs
+++ b/src/librustc_borrowck/diagnostics.rs
@@ -142,23 +142,20 @@ 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:
+For example, this can happen when a drop 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`
+let mut x = Foo { a: 1 };
+drop(x); // `x` is now uninitialized
+x.a = 2; // 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))};
+let mut x = Foo { a: 1 };
+drop(x);
+x = Foo { a: 2 };
 ```
 "##,