-
Notifications
You must be signed in to change notification settings - Fork 256
Closed
Labels
asyncRelated to async/streams in the component model.Related to async/streams in the component model.gen-rustRelated to bindings for Rust-compiled-to-WebAssemblyRelated to bindings for Rust-compiled-to-WebAssembly
Description
When multiple interfaces use the same type from a shared interface (e.g., types.{error-code}) and each return a future parameterized with that type (future<result<_, error-code>>), wit-bindgen generates a separate impl FuturePayload block for each interface's type alias. Since all aliases resolve to the same concrete Rust type, this produces conflicting trait implementations.
Surfaced via the most recent rc (v0.3.0-rc-2026-02-09) where wasi:cli for stdin, stdout, stderr.
tests/codegen/future-shared-type-duplicate-impls.wit:
//@ async = true
package test:shared-future-type;
interface types {
enum error-code {
io,
closed,
}
}
interface a {
use types.{error-code};
f: func() -> future<result<_, error-code>>;
}
interface b {
use types.{error-code};
f: func() -> future<result<_, error-code>>;
}
interface c {
use types.{error-code};
f: func() -> future<result<_, error-code>>;
}
world w {
import a;
import b;
import c;
}
cargo run -- test --languages rust --artifacts ./target/artifacts ./tests/codegen/future-shared-type-duplicate-impls.wit
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.28s
Running `target/debug/wit-bindgen test --languages rust --artifacts ./target/artifacts ./tests/codegen/future-shared-type-duplicate-impls.wit`
Building `wit-bindgen` from crates.io...
=== Running codegen tests ===
running 5 tests
test rust future-shared-type-duplicate-impls.wit-borrowed-duplicate "./tests/codegen/future-shared-type-duplicate-impls.wit" ... FAILED
test rust future-shared-type-duplicate-impls.wit-borrowed "./tests/codegen/future-shared-type-duplicate-impls.wit" ... FAILED
test rust future-shared-type-duplicate-impls.wit-no-std "./tests/codegen/future-shared-type-duplicate-impls.wit" ... ok
test rust future-shared-type-duplicate-impls.wit "./tests/codegen/future-shared-type-duplicate-impls.wit" ... FAILED
test rust future-shared-type-duplicate-impls.wit-async "./tests/codegen/future-shared-type-duplicate-impls.wit" ... FAILED
failures:
---- rust future-shared-type-duplicate-impls.wit-borrowed-duplicate "./tests/codegen/future-shared-type-duplicate-impls.wit" ----
language: rust
variant: future-shared-type-duplicate-impls.wit-borrowed-duplicate
error: failed to codegen test for `rust` over "./tests/codegen/future-shared-type-duplicate-impls.wit"
Caused by:
0: failed to verify generated bindings
1: command execution failed
command: "rustc" "--edition=2021" "--extern=wit_bindgen=/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/rust/wit-bindgen/target/wasm32-wasip2/debug/libwit_bindgen.rlib" "--extern=futures=/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/rust/wit-bindgen/target/wasm32-wasip2/debug/libfutures.rlib" "--target" "wasm32-wasip2" "-Dwarnings" "-Cdebuginfo=1" "-Ldependency=/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/rust/wit-bindgen/target/wasm32-wasip2/debug/deps" "-Ldependency=/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/rust/wit-bindgen/target/debug/deps" "/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/codegen/rust/future-shared-type-duplicate-impls.wit-borrowed-duplicate/bindings/w.rs" "--crate-type=rlib" "-o" "/Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/codegen/rust/future-shared-type-duplicate-impls.wit-borrowed-duplicate/tmp"
status: exit status: 1
stderr:
error[E0119]: conflicting implementations of trait `FuturePayload` for type `Result<(), types::ErrorCode>`
--> /Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/codegen/rust/future-shared-type-duplicate-impls.wit-borrowed-duplicate/bindings/w.rs:378:9
|
265 | / impl super::FuturePayload
266 | | for Result<(), super::super::test::shared_future_type::a::ErrorCode> {
| |____________________________________________________________________________- first implementation here
...
378 | / impl super::FuturePayload
379 | | for Result<(), super::super::test::shared_future_type::b::ErrorCode> {
| |____________________________________________________________________________^ conflicting implementation for `Result<(), types::ErrorCode>`
error[E0119]: conflicting implementations of trait `FuturePayload` for type `Result<(), types::ErrorCode>`
--> /Users/bhayes/repos/bytecodealliance/wit-bindgen/./target/artifacts/codegen/rust/future-shared-type-duplicate-impls.wit-borrowed-duplicate/bindings/w.rs:491:9
|
265 | / impl super::FuturePayload
266 | | for Result<(), super::super::test::shared_future_type::a::ErrorCode> {
| |____________________________________________________________________________- first implementation here
...
491 | / impl super::FuturePayload
492 | | for Result<(), super::super::test::shared_future_type::c::ErrorCode> {
| |____________________________________________________________________________^ conflicting implementation for `Result<(), types::ErrorCode>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0119`.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
asyncRelated to async/streams in the component model.Related to async/streams in the component model.gen-rustRelated to bindings for Rust-compiled-to-WebAssemblyRelated to bindings for Rust-compiled-to-WebAssembly