bytecodealliance / bytecodealliance/wit-bindgen

wit_future FuturePayload implemented for wrong type

Open
#1,628 5 comments 0 reactions 0 assignees View on GitHub
gen-rust
Dominant language
Rust
Stars
1.5k
Forks
286
Avg merge
6h 32m
Merged PRs (30d)
19

Description

Using `wit-bindgen 0.57.1`, I'm implementing a component that interposes `wasi:sockets@0.3`. Both `send` and `receive` on `tcp-socket` use the return type `future>`. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.