@@ -2410,6 +2410,77 @@ fn main() {
24102410```
24112411"## ,
24122412
2413+ E0366 : r##"
2414+ An attempt was made to implement `Drop` on a concrete specialization of a
2415+ generic type. An example is shown below:
2416+
2417+ ```
2418+ struct Foo<T> {
2419+ t: T
2420+ }
2421+
2422+ impl Drop for Foo<u32> {
2423+ fn drop(&mut self) {}
2424+ }
2425+ ```
2426+
2427+ This code is not legal: it is not possible to specialize `Drop` to a subset of
2428+ implementations of a generic type. One workaround for this is to wrap the
2429+ generic type, as shown below:
2430+
2431+ ```
2432+ struct Foo<T> {
2433+ t: T
2434+ }
2435+
2436+ struct Bar {
2437+ t: Foo<u32>
2438+ }
2439+
2440+ impl Drop for Bar {
2441+ fn drop(&mut self) {}
2442+ }
2443+ ```
2444+ "## ,
2445+
2446+ E0367 : r##"
2447+ An attempt was made to implement `Drop` on a specialization of a generic type.
2448+ An example is shown below:
2449+
2450+ ```
2451+ trait Foo{}
2452+
2453+ struct MyStruct<T> {
2454+ t: T
2455+ }
2456+
2457+ impl<T: Foo> Drop for MyStruct<T> {
2458+ fn drop(&mut self) {}
2459+ }
2460+ ```
2461+
2462+ This code is not legal: it is not possible to specialize `Drop` to a subset of
2463+ implementations of a generic type. In order for this code to work, `MyStruct`
2464+ must also require that `T` implements `Foo`. Alternatively, another option is
2465+ to wrap the generic type in another that specializes appropriately:
2466+
2467+ ```
2468+ trait Foo{}
2469+
2470+ struct MyStruct<T> {
2471+ t: T
2472+ }
2473+
2474+ struct MyStructWrapper<T: Foo> {
2475+ t: MyStruct<T>
2476+ }
2477+
2478+ impl <T: Foo> Drop for MyStructWrapper<T> {
2479+ fn drop(&mut self) {}
2480+ }
2481+ ```
2482+ "## ,
2483+
24132484E0368 : r##"
24142485This error indicates that a binary assignment operator like `+=` or `^=` was
24152486applied to the wrong types. For example:
@@ -2641,8 +2712,6 @@ register_diagnostics! {
26412712 E0325 , // implemented an associated type when another trait item expected
26422713 E0328 , // cannot implement Unsize explicitly
26432714 E0329 , // associated const depends on type parameter or Self.
2644- E0366 , // dropck forbid specialization to concrete type or region
2645- E0367 , // dropck forbid specialization to predicate not in struct/enum
26462715 E0369 , // binary operation `<op>` cannot be applied to types
26472716 E0370 , // discriminant overflow
26482717 E0374 , // the trait `CoerceUnsized` may only be implemented for a coercion
0 commit comments