Skip to main content

E0018: Unknown Struct Field

You referenced a field that doesn't exist on the struct.

Example

struct Point {
x: i64,
y: i64,
}

fn main() {
let p = Point { x: 1, z: 2 }; // Error: struct `Point` has no field named `z`
}

How to fix

Use the correct field name:

struct Point {
x: i64,
y: i64,
}

fn main() {
let p = Point { x: 1, y: 2 }; // OK
}

Or add the field to the struct definition if needed.