Repository navigation
[patch] Derive through the structs a Rust record holds - #315
Merged
Merged
Conversation
…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
|
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.Deriveswalks 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