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

オープン
#250 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
65/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
compilers

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
C++
スター
16.4k
フォーク
539
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Snapchat/Valdi のほかの issue

Snapchat/Valdi の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。