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 holding a struct through an auto-property fails to compile (E0277), because the held struct never derives Clone/Debug/PartialEq #353
The #302 fix (PR #315) makes a struct that a record holds derive Clone, Debug, PartialEq along with the record. It only follows fields, though, not auto-properties:
The record: it is lowered with Separated(classDecl) (Coder/Languages/RustGenerator.cs:~501). Its own derive check therefore sees the auto-property as a field, and the record derives.
The held struct: when it is written, Derives (:~739, loop at :~756) walks the original records from GenerationRoot.
Why the walk misses it:UnderivableReason collects held types only from VariableDeclaration and non-associated FieldDeclaration members (:812-818). A bodiless PropertyDeclaration, which Rust emits as a field, is never walked, so the struct behind it is never marked to derive.
Repro
A SourceFile with:
struct Inner { int x } (plain struct)
a record struct Outer whose only member is new PropertyDeclaration("Value", "Inner")
rustc rejects it: error[E0277]: the trait bound Inner: Clone is not satisfied (and the same for Debug and PartialEq).
The same document with VariableDeclaration("value", "Inner") in place of the property generates #[derive(...)] on Inner and compiles. Reproduced at HEAD 1173b65.
Suggested fix
Make the record walk in UnderivableReason / Derives see what Rust actually emits. Either walk Separated(record), or add a PropertyDeclaration arm for auto-properties (no getter or setter body) that yields its Type.
Acceptance criteria
A RustGeneratedSourceCompilesTests case (record → auto-property → plain struct) compiles under rustc.
A record → auto-property → struct → field → struct chain derives transitively, as fields already do.
Priority: Medium. Rust output fails to compile (E0277) for a record that holds a plain struct through an auto-property. The field form works, which is a workaround for document authors.
Area:Coder/Languages/RustGenerator.cs: UnderivableReason / Derives record walk
Activity
matt-edmondson commentedon Oct 29, 2026
Triage
Coder/Languages/RustGenerator.cs:UnderivableReason/Derivesrecord walk.clone()route, so fixing this one first helps there.Generated by Claude Code