E0417: Destructor unknown type
| Code | Category | Stability |
|---|---|---|
E0417 | Struct and enum | Permanent |
Explanation
A top-level drop fn names a type that is not a struct defined in the same module. Destructor target lookup is module-local, so a struct elsewhere in the program does not satisfy the declaration.
Likely cause
The type name is misspelled, the struct declaration is missing from this module, or the name denotes a non-struct type. Declare the struct in the same module and make the destructor's type name match it exactly.
Examples
Destructor for an unknown type
drop fn Resource(self) {}
fn main() -> i32 { 0 }
Define the destructor's struct type
struct Resource { value: i32 }
drop fn Resource(self) {}
fn main() -> i32 { 0 }