@@ -2429,6 +2429,77 @@ fn main() {
24292429```
24302430"## ,
24312431
2432+ E0366 : r##"
2433+ An attempt was made to implement `Drop` on a concrete specialization of a
2434+ generic type. An example is shown below:
2435+
2436+ ```
2437+ struct Foo<T> {
2438+ t: T
2439+ }
2440+
2441+ impl Drop for Foo<u32> {
2442+ fn drop(&mut self) {}
2443+ }
2444+ ```
2445+
2446+ This code is not legal: it is not possible to specialize `Drop` to a subset of
2447+ implementations of a generic type. One workaround for this is to wrap the
2448+ generic type, as shown below:
2449+
2450+ ```
2451+ struct Foo<T> {
2452+ t: T
2453+ }
2454+
2455+ struct Bar {
2456+ t: Foo<u32>
2457+ }
2458+
2459+ impl Drop for Bar {
2460+ fn drop(&mut self) {}
2461+ }
2462+ ```
2463+ "## ,
2464+
2465+ E0367 : r##"
2466+ An attempt was made to implement `Drop` on a specialization of a generic type.
2467+ An example is shown below:
2468+
2469+ ```
2470+ trait Foo{}
2471+
2472+ struct MyStruct<T> {
2473+ t: T
2474+ }
2475+
2476+ impl<T: Foo> Drop for MyStruct<T> {
2477+ fn drop(&mut self) {}
2478+ }
2479+ ```
2480+
2481+ This code is not legal: it is not possible to specialize `Drop` to a subset of
2482+ implementations of a generic type. In order for this code to work, `MyStruct`
2483+ must also require that `T` implements `Foo`. Alternatively, another option is
2484+ to wrap the generic type in another that specializes appropriately:
2485+
2486+ ```
2487+ trait Foo{}
2488+
2489+ struct MyStruct<T> {
2490+ t: T
2491+ }
2492+
2493+ struct MyStructWrapper<T: Foo> {
2494+ t: MyStruct<T>
2495+ }
2496+
2497+ impl <T: Foo> Drop for MyStructWrapper<T> {
2498+ fn drop(&mut self) {}
2499+ }
2500+ ```
2501+ "## ,
2502+
24322503E0368 : r##"
24332504This error indicates that a binary assignment operator like `+=` or `^=` was
24342505applied to the wrong types. For example:
@@ -2659,8 +2730,6 @@ register_diagnostics! {
26592730 E0325 , // implemented an associated type when another trait item expected
26602731 E0328 , // cannot implement Unsize explicitly
26612732 E0329 , // associated const depends on type parameter or Self.
2662- E0366 , // dropck forbid specialization to concrete type or region
2663- E0367 , // dropck forbid specialization to predicate not in struct/enum
26642733 E0369 , // binary operation `<op>` cannot be applied to types
26652734 E0370 , // discriminant overflow
26662735 E0374 , // the trait `CoerceUnsized` may only be implemented for a coercion
0 commit comments