E0060

E0060#

Warning name: unused_struct_update

Unused struct update.

This warning is emitted when a struct update expression is computed but its result is not used. Use the updated value, or remove the update if it is unnecessary.

Erroneous example#

priv struct User {
  id : Int
  name : String
  email : String
}

test {
  let user : User = { id: 0, name: "John Doe", email: "john@doe.com" }
  let _ = { ..user, id: 1, name: "Jane", email: "jane@doe.com" }
}

Suggestion#

Use the updated value, or remove the struct update:

priv struct User {
  id : Int
  name : String
  email : String
}

test {
  let user : User = { id: 0, name: "John Doe", email: "john@doe.com" }
  let updated = { ..user, email: "john@doe.name" }
  ignore(updated)
}