You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
CAD97
added
the
A-docs
Area: documentation for any part of the project, including the compiler, standard library, and tools
label
Jul 7, 2022
Rollup merge of rust-lang#127949 - princess-entrapta:master, r=tgross35
fix: explain E0120 better cover cases when its raised
Fixesrust-lang#98996
Wording change on the explain of E0120 as requested
Location
https://doc.rust-lang.org/nightly/error-index.html#E0120
Summary
E0120 says
The inline note is
(Bonus: --explain should include unions as allowed.)
However, E0120 is emitted for impl target types which are fundamental types but not trait objects:
(see also #36061; E0210 should probably be preferred here and suppress E0120)
(E0117 should probably be preferred here and suppress E0120)
The --explain text should be adjusted to something along the lines of
and have its examples updated to match the new byline.
The text was updated successfully, but these errors were encountered: