Rust codegen: Empty @ExportModule / @ExportProxy generates invalid Rust and C output

オープン 初心者向け
#245 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

compiler/compiler/Compiler/Sources/Generation/Rust/RustModuleGenerator.swift と RustProxyGenerator.swift を読み、issue が空のメソッドに対する出力経路として特定している箇所を確認してください。生成される Rust と C の出力が、空でないメソッドリストをどのように扱うかを確認し、空の @ExportModule と @ExportProxy のケースをテストに追加してください。これらのケースで空の enum を含まない有効な Rust と C の出力が生成されれば完了です。

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

説明

Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.

Empty @ExportModule generates invalid Rust match syntax and empty C enum

File: compiler/compiler/Compiler/Sources/Generation/Rust/RustModuleGenerator.swift

When an @ExportModule has no methods, invokeCases is empty and the generated match method arm emits a leading comma (match method { , _ => ... }), and the generated C header emits an empty enum { };, both of which fail to compile.

Only emit the trailing comma after \(invokeCases) when methods is non-empty, and omit the enum { ... }; block in cHeader when methods is empty.

Empty @ExportProxy generates invalid Rust match syntax

File: compiler/compiler/Compiler/Sources/Generation/Rust/RustProxyGenerator.swift

When an @ExportProxy interface has no methods, invokeCases is empty and the generated match method emits a leading comma (match method { , _ => ... }), which fails to compile in Rust.

Only emit the trailing comma after \(invokeCases) when methods is non-empty.

主要言語
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 を短くまとめたダイジェスト。