]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0366.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0366.md
1 An attempt was made to implement `Drop` on a concrete specialization of a
2 generic type. An example is shown below:
3
4 ```compile_fail,E0366
5 struct Foo<T> {
6     t: T
7 }
8
9 impl Drop for Foo<u32> {
10     fn drop(&mut self) {}
11 }
12 ```
13
14 This code is not legal: it is not possible to specialize `Drop` to a subset of
15 implementations of a generic type. One workaround for this is to wrap the
16 generic type, as shown below:
17
18 ```
19 struct Foo<T> {
20     t: T
21 }
22
23 struct Bar {
24     t: Foo<u32>
25 }
26
27 impl Drop for Bar {
28     fn drop(&mut self) {}
29 }
30 ```