Skip to content

[patch] Derive through the structs a Rust record holds - #315

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/project-thread-kddtpg-302
Oct 25, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/project-thread-kddtpg-302

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Before: a Rust record (IsRecord) got #[derive(Clone, Debug, PartialEq)], but a plain struct it held got nothing, so the record's derive did not compile.

After: every struct a record reaches derives with it. A record holding something that cannot derive (a trait, a type not declared in the file, an untyped object) gets a note saying why instead of a derive that would not compile.

How: RustGenerator.Derives walks the record's base type and field types, following aliases and type arguments, and treats a struct as deriving when a derivable record reaches it. A new rustc compile test (RecordsHoldingStructsAndRecords_Compile) checks a record holding a struct, a list of structs, another record and an enum.

Fixes #302


Generated by Claude Code

…record holds

A record's derive needs every field type to implement the same traits, so a
record holding a plain struct did not compile. The structs a record reaches
now derive with it, and a record that holds something which cannot derive
(a trait, an undeclared type, an untyped value) writes a note saying why
instead of a derive that would not compile.

Fixes #302

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1CFbhzg3saCCjeDAZC7Pd
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: a record with a field of a plain struct type doesn't compile (E0277/E0369) because only the record derives Clone/Debug/PartialEq

2 participants