Tried to set a field that the struct doesn't declare.
struct User { id: u64, name: String }
let u = User { id: 1, name: "ada".into(), email: "a@b".into() };
// E0560: User has no field named `email`
Struct literal syntax must list exactly the declared fields. The compiler refuses unknown names — it's almost always a typo or stale caller after a refactor.
- Remove the extra field from the literal, or add it to the struct definition.
- For optional fields, use Option<T> and ..Default::default() to fill the rest.
- After renaming a field, search the codebase — the compiler points at every stale call.
- For evolving APIs, consider #[non_exhaustive] on the struct so callers must use a constructor.