Description
Location
https://doc.rust-lang.org/nightly/error-index.html#E0120
Summary
E0120 says
Drop was implemented on a trait, which is not allowed: only structs and enums can implement Drop.
The inline note is
the
Drop
trait may only be implemented for structs, enums, and unions
(Bonus: --explain should include unions as allowed.)
However, E0120 is emitted for impl target types which are fundamental types but not trait objects:
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
--> src/lib.rs:2:15
|
2 | impl Drop for &'_ mut Concrete {
| ^^^^^^^^^^^^^^^^ must be a struct, enum, or union
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> src/lib.rs:2:6
|
2 | impl<T: Trait> Drop for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
--> src/lib.rs:2:25
|
2 | impl<T: Trait> Drop for T {
| ^ must be a struct, enum, or union
(see also #36061; E0210 should probably be preferred here and suppress E0120)
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> src/lib.rs:2:1
|
2 | impl Drop for *mut Concrete {
| ^^^^^^^^^^^^^^-------------
| | |
| | `*mut Concrete` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
error[E0120]: the `Drop` trait may only be implemented for structs, enums, and unions
--> src/lib.rs:2:15
|
2 | impl Drop for *mut Concrete {
| ^^^^^^^^^^^^^ must be a struct, enum, or union
(E0117 should probably be preferred here and suppress E0120)
The --explain text should be adjusted to something along the lines of
Drop was implemented on a trait object or reference, which is not allowed; only structs, enums, and unions can implement Drop.
and have its examples updated to match the new byline.