IDL→Rust codegen: a
|
| # | Alternative | Finding |
|---|---|---|
| 1 | A RustGenOptions flag relaxing key handling |
RustGenOptions has two fields only: header_comment and cdr_only. cdr_only omits the entire DdsType impl (the CORBA/GIOP path), so it does not apply to a DDS data type. |
| 2 | Declaring the key with the primitive inline | Would mean changing an IDL baseline to accommodate a tool limitation, altering a published type contract. Rejected. |
| 3 | A pre-pass on the AST before codegen | Works — see below — but is a downstream workaround, not a fix. |
Workaround we are using
An AST pre-pass that collects typedef aliases of primitives and rewrites @key members typed with such an alias to the underlying primitive before calling generate_rust_module. Roughly 150 lines. It touches key members only, so non-key field types are unchanged, and it refuses to rewrite where one simple name maps to two different bases rather than guessing.
With it, every file in our set generates.
Suggested fix
In the key-field emission path, before returning Unsupported, resolve the scoped name against the typedef declarations already present in the AST, and where it resolves (transitively) to a primitive, emit the key-holder write for that primitive — the same code path case (2) already takes.
We have not attempted a patch against the real codebase; we would rather keep testing the unmodified published artefact. Happy to supply the pre-pass and the reduced reproducer project if useful.
Replies: 2 comments
|
The key-field emitter never dealiases typedefs. In Workaround until it's fixed: type the @key field with the underlying primitive directly ( |
|
Thank you, @swarm59, for the precise report and minimal reproducer, and thank you, @sueun-dev, for tracing it to the exact KeyHolder branch and documenting a useful workaround. You were both right: the Rust key path followed a scoped type only when it resolved to a struct, so a typedef ending in a primitive fell through to the generic “complex key” error. This is fixed on Your report also gave us the entry point for a much broader KeyHash audit. We found and fixed related cases beyond the original Rust failure: C# could silently omit typedef-aliased or nested-struct key material; C++, Java, and TypeScript could use the full nested struct instead of its key subset or apply inconsistent member ordering; array declarators and typedef indirection exposed further over- and under-inclusion paths; and the corresponding thin-backend paths were checked and corrected where necessary. These cases are now covered by cross-backend KeyHash and generated-code tests rather than only the original reproducer. One independently scoped limitation remains under active work: member-id ordering under struct-level The complete public I am closing this discussion as fixed. If you still encounter the original failure on current Thank you again for helping us improve considerably more than the single path in the original report. |
Thank you, @swarm59, for the precise report and minimal reproducer, and thank you, @sueun-dev, for tracing it to the exact KeyHolder branch and documenting a useful workaround. You were both right: the Rust key path followed a scoped type only when it resolved to a struct, so a typedef ending in a primitive fell through to the generic “complex key” error.
This is fixed on
maininbd7e592. Key fields are now dealiased before KeyHolder sizing and emission, with regression coverage for primitive, string, chained-alias, and nested-struct cases.Your report also gave us the entry point for a much broader KeyHash audit. We found and fixed related cases beyond the original Rust failure: C# could…