Skip to content

Commit 79f3ce3

Browse files
committed
avoid generating duplicate stream and future constructors
Previously, we used the payload type to avoid generating duplicates, but that doesn't work reliably because `wit-parser` does not necessarily deduplicate types involving aliases, such as the following example: ``` interface types { variant foo { bar, baz } } interface use-types-a { use types.{foo}; test: func() -> future<result<foo>>; } interface use-types-b { use types.{foo}; test: func() -> future<result<foo>>; } ``` When targetting a world which imports and/or exports both `use-types-a` and `use-types-b`, we'll end up with distinct type IDs for `result<foo>`. This commit switches to using `wit-bindgen-core` to determine the "canonical" type of the payload and then use that as the deduplication key. This unblocks using `wasi:cli@0.3.0-rc-2026-02-09`, which has a similar pattern to the above WIT example. Note that this is awkward to test given our current test infra, but #205 will cover it once it's merged.
1 parent df7c6cc commit 79f3ce3

File tree

5 files changed

+158
-46
lines changed

5 files changed

+158
-46
lines changed

Cargo.lock

Lines changed: 111 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ clap = { version = "4.5.20", features = ["derive"] }
1414
tar = "0.4.42"
1515
tempfile = "3.13.0"
1616
zstd = "0.13.2"
17-
wasm-encoder = { version = "0.244.0", features = ["wasmparser"] }
18-
wit-dylib = "0.244.0"
19-
wit-parser = "0.244.0"
20-
wit-component = "0.244.0"
21-
wasmparser = "0.244.0"
17+
wasm-encoder = { version = "0.245.0", features = ["wasmparser"] }
18+
wit-dylib = "0.245.0"
19+
wit-parser = "0.245.0"
20+
wit-component = "0.245.0"
21+
wasmparser = "0.245.0"
2222
indexmap = "2.6.0"
2323
bincode = "1.3.3"
2424
heck = "0.5.0"
@@ -45,6 +45,7 @@ im-rc = "15.1.0"
4545
serde = { version = "1.0.213", features = ["derive"] }
4646
toml = "0.8.19"
4747
semver = "1.0.23"
48+
wit-bindgen-core = "0.53.1"
4849

4950
[dev-dependencies]
5051
assert_cmd = "2.0.16"

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub async fn componentize(
372372
docs: Default::default(),
373373
stability: Stability::Unknown,
374374
includes: Default::default(),
375-
include_names: Default::default(),
375+
span: Default::default(),
376376
});
377377

378378
resolve.packages[union_package]
@@ -803,7 +803,7 @@ fn add_wasi_and_stubs(
803803
.or_default()
804804
.push(Stub::Function(&function.name, &function.kind));
805805
}
806-
WorldItem::Type(id) => {
806+
WorldItem::Type { id, .. } => {
807807
let ty = &resolve.types[*id];
808808
if let TypeDefKind::Resource = &ty.kind {
809809
stubs

0 commit comments

Comments
 (0)