File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
compiler/rustc_error_codes/src/error_codes Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1
- Drop was implemented on a trait, which is not allowed: only structs and
2
- enums can implement Drop.
1
+ Drop was implemented on a trait object or reference , which is not allowed; only
2
+ structs, enums, and unions can implement Drop.
3
3
4
- Erroneous code example :
4
+ Erroneous code examples :
5
5
6
6
``` compile_fail,E0120
7
7
trait MyTrait {}
@@ -11,7 +11,15 @@ impl Drop for MyTrait {
11
11
}
12
12
```
13
13
14
- A workaround for this problem is to wrap the trait up in a struct, and implement
14
+ ``` compile_fail,E0120
15
+ struct Concrete {}
16
+
17
+ impl Drop for &'_ mut Concrete {
18
+ fn drop(&mut self) {}
19
+ }
20
+ ```
21
+
22
+ A workaround for traits is to wrap the trait up in a struct, and implement
15
23
Drop on that:
16
24
17
25
```
You can’t perform that action at this time.
0 commit comments