File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -1316,6 +1316,45 @@ fn main() {
13161316```
13171317"## ,
13181318
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+
13191358E0121 : r##"
13201359In order to be consistent with Rust's lack of global type inference, type
13211360placeholders are disallowed by design in item signatures.
@@ -2195,7 +2234,6 @@ register_diagnostics! {
21952234 E0103 ,
21962235 E0104 ,
21972236 E0118 ,
2198- E0120 ,
21992237 E0122 ,
22002238 E0123 ,
22012239 E0127 ,
You can’t perform that action at this time.
0 commit comments