E0412: Undefined assoc fn
| Code | Category | Stability |
|---|---|---|
E0412 | Struct and enum | Permanent |
Explanation
An associated-style call names no callable member on the selected type. For a struct, the missing member would be an associated function declared without self; this code also covers a missing called variant on an inline comptime-produced enum type.
Likely cause
The member or type name is wrong, a struct method requiring a receiver value was intended, or an inline comptime-produced enum has no variant with the called name. Check the selected type's declarations and use the call form that matches the intended member.
Examples
Unknown associated function
struct Point { x: i32 }
fn main() -> i32 {
Point.origin().x
}
Declare and call an associated function
struct Point {
x: i32,
fn origin() -> Point { Point { x: 0 } }
}
fn main() -> i32 {
Point.origin().x
}