Skip to content

wit_future FuturePayload implemented for wrong type #1628

@scothis

Description

@scothis

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<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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions