wit_future FuturePayload implemented for wrong type

Đang mở
#1,628 5 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust, wasm
Lĩnh vực
devtools

Hướng nghiên cứu

Tái hiện báo cáo bằng ví dụ src/lib.rs và kiểm tra các bindings được tạo bằng cargo expand. So sánh các triển khai FuturePayload cho các kiểu ErrorCode được import và export; hoàn tất khi các phương thức future<result<_, error-code>> được export biên dịch mà không cần triển khai trait thủ công.

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

Mô tả

gen-rust

Using wit-bindgen 0.57.1, I'm implementing a component that interposes wasi:[email protected]. Both send and receive on tcp-socket use the return type future<result<_, error-code>>. When implementing these methods, I get the error:

error[E0277]: the trait bound `Result<_, exports::wasi::sockets::types::ErrorCode>: FuturePayload` is not satisfied
    --> src/lib.rs:325:40
     |
 325 |         let (tx, rx) = wit_future::new(|| Err(ErrorCode::Other(None)));
     |                        --------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FuturePayload` is not implemented for `Result<_, exports::wasi::sockets::types::ErrorCode>`
     |                        |
     |                        required by a bound introduced by this call
     |
help: the trait `FuturePayload` is implemented for `Result<(), wasi::sockets::types::ErrorCode>`

The FuturePayload trait is implemented for the imported type, but not implemented for the exported type.

If I manually implement the trait for the exported type using the output of cargo expand, replacing the ErrorCode type with the exports version, everything compiles as expected.

The project as a whole is a work in progress, but I can push the code if that helps.

Ngôn ngữ chính
Rust
Star
1.5k
Fork
306
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
21

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

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 bytecodealliance/wit-bindgen

Tất cả issue của bytecodealliance/wit-bindgen

Issue tương tự

Thêm issue về Rust

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.