diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-05-03 12:41:48 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-06-13 11:05:13 -0700 |
| commit | 9e2ee322e84eb63d3fc2c9f6d11131f74d3f4dea (patch) | |
| tree | 10bfc19324bf3e2ef1d48f65e41783e5ddafaec5 | |
| parent | 21ddf4d903762bb0af92ee0b63140544b8f0fbd2 (diff) | |
| download | rust-9e2ee322e84eb63d3fc2c9f6d11131f74d3f4dea.tar.gz rust-9e2ee322e84eb63d3fc2c9f6d11131f74d3f4dea.zip | |
Update incorrect error code docs
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0493.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/librustc_error_codes/error_codes/E0493.md b/src/librustc_error_codes/error_codes/E0493.md index 90a0cbce623..0dcc3b62b4b 100644 --- a/src/librustc_error_codes/error_codes/E0493.md +++ b/src/librustc_error_codes/error_codes/E0493.md @@ -1,5 +1,4 @@ -A type with a `Drop` implementation was destructured when trying to initialize -a static item. +A value with a custom `Drop` implementation may be dropped during const-eval. Erroneous code example: @@ -16,13 +15,14 @@ struct Foo { field1: DropType, } -static FOO: Foo = Foo { ..Foo { field1: DropType::A } }; // error! +static FOO: Foo = Foo { field1: (DropType::A, DropType::A).1 }; // error! ``` The problem here is that if the given type or one of its fields implements the -`Drop` trait, this `Drop` implementation cannot be called during the static -type initialization which might cause a memory leak. To prevent this issue, -you need to instantiate all the static type's fields by hand. +`Drop` trait, this `Drop` implementation cannot be called within a const +context since it may run arbitrary, non-const-checked code. To prevent this +issue, ensure all values with custom a custom `Drop` implementation escape the +initializer. ``` enum DropType { |
