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: generated enums derive nothing, so comparing two enum values fails (E0369) and a record holding an enum field fails (E0277) #255
RustGenerator.GenerateEnumDeclaration (Coder/Languages/RustGenerator.cs ~L1677-L1702) writes at most a #[repr(...)] and never a #[derive(...)]. Record structs, by contrast, get #[derive(Clone, Debug, PartialEq)] (~L591-L595), which requires every field type to implement those traits.
The comment at ~L414-L416 explains why plain structs derive nothing: one of their fields might not implement the traits. That reason can't apply to a fieldless C-like enum, which can always derive Clone, Copy, Debug, PartialEq, Eq, Hash.
RustGeneratedSourceCompilesTests declares CompiledExemplar.Colour() (~L503) but never compares it, copies it, or holds it in a record, so the compile test passes.
Failure scenarios (portable AST, accepted by the other six targets)
bool same(Colour a, Colour b) { return a == b; }, built from VariableReferences and BinaryOperator.Equal, fails with E0369: binary operation == cannot be applied to type Colour.
A ClassDeclaration { IsRecord = true } with a Colour field fails with E0277: Colour doesn't implement Clone/Debug/PartialEq, which the record's derive needs.
A method reading an enum field by value from &self fails with E0507 (cannot move out of self.colour), because the enum isn't Copy.
Suggested fix
Write #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] on every generated enum, placed directly above the enum line, after the preamble and #[repr].
Priority: Medium. The Rust output fails to compile for ordinary uses of an enum: comparing values, holding one in a record, or reading one from &self. The failure is at compile time, so it isn't silent.
Area / suggested assignee:RustGenerator.GenerateEnumDeclaration and RustGeneratedSourceCompilesTests. Owner: @matt-edmondson
Duplicates / in progress: none found. No open PR covers it.
Next step: emit #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] on every fieldless enum. Extend the compile test with the three scenarios in the issue.
Activity
matt-edmondson commentedon Oct 18, 2026
Triage
&self. The failure is at compile time, so it isn't silent.RustGenerator.GenerateEnumDeclarationandRustGeneratedSourceCompilesTests. Owner: @matt-edmondson#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]on every fieldless enum. Extend the compile test with the three scenarios in the issue.Generated by Claude Code