You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rust: a record with a field of a plain struct type doesn't compile (E0277/E0369) because only the record derives Clone/Debug/PartialEq #302
RustGenerator deliberately derives nothing on plain structs; the remarks around Coder/Languages/RustGenerator.cs L413-416 explain why. It does, however, write #[derive(Clone, Debug, PartialEq)] on every IsRecord type (around L591-595). As soon as a record has a field whose type is a non-record struct declared in the same tree, the record's derive can't be satisfied.
Reproduction
A plain struct Point { int x } plus a record struct Line { Point a } generates:
error[E0277]: the trait bound 'Point: Clone' is not satisfied
error[E0277]: 'Point' doesn't implement 'Debug'
error[E0369]: binary operation '==' cannot be applied to type 'Point'
The C# output for the same AST (record struct Line { public Point a; }) compiles.
#255 and open PR #263 fix this same failure for enum fields only. Struct fields aren't covered.
Suggested fix
When a record's field type names a struct declared in the generation root, give that struct the same derive, transitively. Field types include type arguments and array element types. When the field type isn't declared in the tree, or is an interface or trait, write the inexpressible note instead of a derive that can't compile. Sharing the "which types need the derive" walk with the #255 enum fix would keep the two consistent.
Acceptance criteria
RustGeneratedSourceCompilesTests has a case for a record holding a plain struct, and one for a record holding another record.
A plain struct that no record uses still gets no derive.
Activity
matt-edmondson commentedon Oct 19, 2026
Triage
Coder/Languages/RustGenerator.cs(~L413-416,~L591-595). Owner: @matt-edmondsonoperator ==doesn't compile in C# (CS0111) or Rust (E0119) because the record already supplies equality #301, which requires droppingPartialEqfrom the derive when a record declares==.operator ==doesn't compile in C# (CS0111) or Rust (E0119) because the record already supplies equality #301'sPartialEqexclusion in the same place, and add the record-holds-struct and record-holds-record compile tests.Generated by Claude Code