diff --git a/scripts/codegen/rust.ts b/scripts/codegen/rust.ts index b3cc5d5753..776f468495 100644 --- a/scripts/codegen/rust.ts +++ b/scripts/codegen/rust.ts @@ -85,6 +85,12 @@ const STRING_NEWTYPE_OVERRIDES: Record = { requestId: "RequestId", }; +const STRING_ENUM_VARIANT_OVERRIDES: Record> = { + CatalogTrustEligibility: { + unknown: "UnknownValue", + }, +}; + // ── Naming helpers ────────────────────────────────────────────────────────── function toPascalCase(s: string): string { @@ -115,8 +121,9 @@ function uniqueRustPascalIdentifier( used: Set, fallback: string, reserved: Set = new Set(), + override?: string, ): string { - const identifier = toRustPascalIdentifier(value, fallback); + const identifier = override ?? toRustPascalIdentifier(value, fallback); if (used.has(identifier) || reserved.has(identifier)) { throw new Error( `Generated Rust enum variant identifier "${identifier}" is not unique for value "${value}". Add an explicit naming rule instead of stabilizing an arbitrary public variant name.`, @@ -1045,6 +1052,7 @@ function emitRustStringEnum( usedVariantNames, "Value", reservedVariantNames, + STRING_ENUM_VARIANT_OVERRIDES[enumName]?.[value], ); pushRustDoc(lines, enumValueDescriptions?.[value], " "); if (variantName !== value) {