@@ -1128,6 +1128,51 @@ Remember this solution is unsafe! You will have to ensure that accesses to the
1128
1128
cell are synchronized.
1129
1129
"## ,
1130
1130
1131
+ E0493 : r##"
1132
+ A type with a `Drop` implementation was destructured when trying to initialize
1133
+ a static item.
1134
+
1135
+ Erroneous code example:
1136
+
1137
+ ```compile_fail,E0493
1138
+ enum DropType {
1139
+ A,
1140
+ }
1141
+
1142
+ impl Drop for DropType {
1143
+ fn drop(&mut self) {}
1144
+ }
1145
+
1146
+ struct Foo {
1147
+ field1: DropType,
1148
+ }
1149
+
1150
+ static FOO: Foo = Foo { ..Foo { field1: DropType::A } }; // error!
1151
+ ```
1152
+
1153
+ The problem here is that if the given type or one of its fields implements the
1154
+ `Drop` trait, this `Drop` implementation cannot be called during the static
1155
+ type initialization which might cause a memory leak. To prevent this issue,
1156
+ you need to instantiate all the static type's fields by hand.
1157
+
1158
+ ```
1159
+ enum DropType {
1160
+ A,
1161
+ }
1162
+
1163
+ impl Drop for DropType {
1164
+ fn drop(&mut self) {}
1165
+ }
1166
+
1167
+ struct Foo {
1168
+ field1: DropType,
1169
+ }
1170
+
1171
+ static FOO: Foo = Foo { field1: DropType::A }; // We initialize all fields
1172
+ // by hand.
1173
+ ```
1174
+ "## ,
1175
+
1131
1176
E0499 : r##"
1132
1177
A variable was borrowed as mutable more than once. Erroneous code example:
1133
1178
@@ -2391,7 +2436,6 @@ There are some known bugs that trigger this message.
2391
2436
// E0299, // mismatched types between arms
2392
2437
// E0471, // constant evaluation error (in pattern)
2393
2438
// E0385, // {} in an aliasable location
2394
- E0493 , // destructors cannot be evaluated at compile-time
2395
2439
E0521 , // borrowed data escapes outside of closure
2396
2440
E0524 , // two closures require unique access to `..` at the same time
2397
2441
E0526 , // shuffle indices are not constant
0 commit comments