Skip to content

Commit 9e2ee32

Browse files
Update incorrect error code docs
1 parent 21ddf4d commit 9e2ee32

File tree

1 file changed

+6
-6
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+6
-6
lines changed

src/librustc_error_codes/error_codes/E0493.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
A type with a `Drop` implementation was destructured when trying to initialize
2-
a static item.
1+
A value with a custom `Drop` implementation may be dropped during const-eval.
32

43
Erroneous code example:
54

@@ -16,13 +15,14 @@ struct Foo {
1615
field1: DropType,
1716
}
1817
19-
static FOO: Foo = Foo { ..Foo { field1: DropType::A } }; // error!
18+
static FOO: Foo = Foo { field1: (DropType::A, DropType::A).1 }; // error!
2019
```
2120

2221
The problem here is that if the given type or one of its fields implements the
23-
`Drop` trait, this `Drop` implementation cannot be called during the static
24-
type initialization which might cause a memory leak. To prevent this issue,
25-
you need to instantiate all the static type's fields by hand.
22+
`Drop` trait, this `Drop` implementation cannot be called within a const
23+
context since it may run arbitrary, non-const-checked code. To prevent this
24+
issue, ensure all values with custom a custom `Drop` implementation escape the
25+
initializer.
2626

2727
```
2828
enum DropType {

0 commit comments

Comments
 (0)