Improve code examples for E0383 long diagnostic.
This commit is contained in:
parent
9c0d2b2465
commit
67c7fd710b
1 changed files with 7 additions and 10 deletions
|
@ -142,23 +142,20 @@ E0383: r##"
|
||||||
This error occurs when an attempt is made to partially reinitialize a
|
This error occurs when an attempt is made to partially reinitialize a
|
||||||
structure that is currently uninitialized.
|
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 x = Foo { a: 1 };
|
||||||
let mut u = Test { a: 2, b: Some(Box::new(t))}; // `t` is now uninitialized
|
drop(x); // `x` is now uninitialized
|
||||||
// because ownership has been
|
x.a = 2; // error, partial reinitialization of uninitialized structure `t`
|
||||||
// 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:
|
This error can be fixed by fully reinitializing the structure in question:
|
||||||
|
|
||||||
```
|
```
|
||||||
let mut t = Test { a: 1, b: None};
|
let mut x = Foo { a: 1 };
|
||||||
let mut u = Test { a: 2, b: Some(Box::new(t))};
|
drop(x);
|
||||||
t = Test { a: 1, b: Some(Box::new(u))};
|
x = Foo { a: 2 };
|
||||||
```
|
```
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue