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

Đang mở Phù hợp với người mới
#245 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
build-system

Hướng nghiên cứu

Đọc compiler/compiler/Compiler/Sources/Generation/Rust/RustModuleGenerator.swift và RustProxyGenerator.swift, nơi issue xác định các đường dẫn xuất cho phương thức rỗng. Kiểm tra cách đầu ra Rust và C được tạo xử lý các danh sách phương thức không rỗng, rồi bổ sung kiểm thử cho các trường hợp @ExportModule và @ExportProxy rỗng. Công việc hoàn tất khi các trường hợp đó tạo ra đầu ra Rust và C hợp lệ mà không có enum rỗng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C++
Star
16.4k
Fork
539
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Snapchat/Valdi

Tất cả issue của Snapchat/Valdi

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.