Rust codegen: Callbacks and futures passed as generic model arguments are dropped before definition generation

Aperta
#250 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C++
Stelle
16.4k
Fork
539
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Snapchat/Valdi

Tutte le issue di Snapchat/Valdi

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.