Skip to content

Commit 9d0bca4

Browse files
committed
Rollup merge of #27699 - nathankleyn:diagnostics-383, r=Manishearth
This adds detailed diagnostics for `E0383`, 'partial reinitialization of uninitialized structure'. This is part of #24407. r? @Manishearth
2 parents ea3cd02 + 67c7fd7 commit 9d0bca4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/librustc_borrowck/diagnostics.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,27 @@ Book:
138138
https://doc.rust-lang.org/book/ownership.html
139139
"##,
140140

141+
E0383: r##"
142+
This error occurs when an attempt is made to partially reinitialize a
143+
structure that is currently uninitialized.
144+
145+
For example, this can happen when a drop has taken place:
146+
147+
```
148+
let mut x = Foo { a: 1 };
149+
drop(x); // `x` is now uninitialized
150+
x.a = 2; // error, partial reinitialization of uninitialized structure `t`
151+
```
152+
153+
This error can be fixed by fully reinitializing the structure in question:
154+
155+
```
156+
let mut x = Foo { a: 1 };
157+
drop(x);
158+
x = Foo { a: 2 };
159+
```
160+
"##,
161+
141162
E0384: r##"
142163
This error occurs when an attempt is made to reassign an immutable variable.
143164
For example:
@@ -217,7 +238,6 @@ https://doc.rust-lang.org/std/cell/
217238
}
218239

219240
register_diagnostics! {
220-
E0383, // partial reinitialization of uninitialized structure
221241
E0385, // {} in an aliasable location
222242
E0386, // {} in an immutable container
223243
E0388, // {} in a static location

0 commit comments

Comments
 (0)