Commit bdf447e
Derive Default on generated Rust types (#1272)
* Derive Default on generated Rust types
When the @github/copilot schema gains an optional field on a wire type,
every Rust test fixture that constructs that type by struct literal
breaks until each one is hand-edited (cf.
70eb60e in #1270). Test fixtures
shouldn't have to acknowledge new wire fields they don't care about.
Teach the Rust codegen to derive `Default` on every generated struct
and string-style enum (with `#[default]` on the `Unknown` catch-all
where one exists), and propagate non-default-ness across structs that
have a required field of an untagged-enum type (which has no obvious
default variant). Also derive `Default` on `RequestId` for parity with
`SessionId`. With this in place, the three internal Model fixtures can
spell themselves with `..Default::default()` and survive future
additive schema changes without manual intervention.
Production code stays explicit: the rust-coding skill already forbids
`..Default::default()` outside tests, and that rule is unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Drop redundant model_picker fields after merge
main added explicit None initializers for the new model_picker_*
fields; the merge layered those on top of our ..Default::default()
making them redundant.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Regenerate after merging main
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent e3fd3d0 commit bdf447e
6 files changed
Lines changed: 762 additions & 602 deletions
File tree
- rust
- src
- generated
- tests/e2e
- scripts/codegen
0 commit comments