]> git.lizzy.rs Git - rust.git/commitdiff
Improve code examples for E0383 long diagnostic.
authorNathan Kleyn <nathan@nathankleyn.com>
Thu, 13 Aug 2015 08:11:06 +0000 (09:11 +0100)
committerNathan Kleyn <nathan@nathankleyn.com>
Thu, 13 Aug 2015 08:11:06 +0000 (09:11 +0100)
src/librustc_borrowck/diagnostics.rs

index acd2bf3fba9d6f5a6b1632156b5adbe4c11e8d39..0bc439529260ccab1236c2b4f3d3b53adfaa6989 100644 (file)
@@ -142,23 +142,20 @@ fn main() {
 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 };
 ```
 "##,