File tree 1 file changed +39
-1
lines changed
1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -1316,6 +1316,45 @@ fn main() {
1316
1316
```
1317
1317
"## ,
1318
1318
1319
+ E0120 : r##"
1320
+ An attempt was made to implement Drop on a trait, which is not allowed: only
1321
+ structs and enums can implement Drop. An example causing this error:
1322
+
1323
+ ```
1324
+ trait MyTrait {}
1325
+
1326
+ impl Drop for MyTrait {
1327
+ fn drop(&mut self) {}
1328
+ }
1329
+ ```
1330
+
1331
+ A workaround for this problem is to wrap the trait up in a struct, and implement
1332
+ Drop on that. An example is shown below:
1333
+
1334
+ ```
1335
+ trait MyTrait {}
1336
+ struct MyWrapper<T: MyTrait> { foo: T }
1337
+
1338
+ impl <T: MyTrait> Drop for MyWrapper<T> {
1339
+ fn drop(&mut self) {}
1340
+ }
1341
+
1342
+ ```
1343
+
1344
+ Alternatively, wrapping trait objects requires something like the following:
1345
+
1346
+ ```
1347
+ trait MyTrait {}
1348
+
1349
+ //or Box<MyTrait>, if you wanted an owned trait object
1350
+ struct MyWrapper<'a> { foo: &'a MyTrait }
1351
+
1352
+ impl <'a> Drop for MyWrapper<'a> {
1353
+ fn drop(&mut self) {}
1354
+ }
1355
+ ```
1356
+ "## ,
1357
+
1319
1358
E0121 : r##"
1320
1359
In order to be consistent with Rust's lack of global type inference, type
1321
1360
placeholders are disallowed by design in item signatures.
@@ -2195,7 +2234,6 @@ register_diagnostics! {
2195
2234
E0103 ,
2196
2235
E0104 ,
2197
2236
E0118 ,
2198
- E0120 ,
2199
2237
E0122 ,
2200
2238
E0123 ,
2201
2239
E0127 ,
You can’t perform that action at this time.
0 commit comments