Rust codegen: Callbacks and futures passed as generic model arguments are dropped before definition generation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Start in RustTypeResolver.swift at resolve(_:namePath:) and trace how generic model arguments are represented in RustTypes.swift. Then inspect RustReferencedTypeGenerator.swift at collectTypes and the Rust code generation tests for generic models containing callbacks or Promise values. Done means the generated definitions include those callback or future types and the generated Rust compiles.
Written by the indexing model from the issue text.
Description
Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.
Callbacks and futures passed as generic model arguments are dropped before definition generation
File: compiler/compiler/Compiler/Sources/Generation/Rust/RustTypeResolver.swift
When a callback or Promise is passed as a type argument to a generic model (such as Boxed<(x: number) => void> or Boxed<Promise<number>>), the generated Rust code fails to compile because the callback or future type is never defined. In resolve(_:namePath:), the .genericObject branch formats resolvedArguments into strings and discards the resolved RustType values by returning .model(rust:borrowed:).
Because RustReferencedTypeGenerator.collectTypes in compiler/compiler/Compiler/Sources/Generation/Rust/RustReferencedTypeGenerator.swift only recurses into .callback, .future, .valueArray, and .nullable, callbacks and futures inside generic model arguments are never collected or emitted, leaving undefined type references in the generated module or function signatures.
Preserve the resolved generic argument RustType values on a .genericModel (or .model) case in compiler/compiler/Compiler/Sources/Generation/Rust/RustTypes.swift and traverse them in RustReferencedTypeGenerator.collectTypes.
- Dominant language
- C++
- Stars
- 16.4k
- Forks
- 539
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Snapchat/Valdi
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Rust codegen: RustMethodResolver fails to unwrap .nullable on optional interface/module methodsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
Maintainers usually reply within 1 day
-
bug needs testing platform:windows topic:buildsystem topic:platforms
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#126110 · 1 comment ·
Maintainers usually reply within 1 day
-
comp-s3queue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ClickHouse/ClickHouse#137649 ·
Maintainers usually reply within 1 day
-
area/docdb kind/enhancement mvu-pg15-pg19 priority/low
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
yugabyte/yugabyte-db#40355 ·
Maintainers usually reply within 1 day
-
Clear params.inputs in dials.indexPossibly taken @phyy-nx claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dials/dials#3361 · 1 comment ·
Maintainers usually reply within 1 day