Skip to content

wit-bindgen 0.42#1352

Merged
rvolosatovs merged 72 commits into
mainfrom
merge/wit-bindgen-0.42
Jun 23, 2026
Merged

wit-bindgen 0.42#1352
rvolosatovs merged 72 commits into
mainfrom
merge/wit-bindgen-0.42

Conversation

@rvolosatovs

Copy link
Copy Markdown
Member

Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree.

  • Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230.
  • Adapt to the wit-parser 0.230 API break: TypeDefKind gained a
    FixedSizeList(Type, u32) variant. Handle it in the introspection async-path
    walk like a List (element indexed by a wildcard path), and add arms to the
    Rust and Go generators' type/codec matches. Full fixed-size-list code
    generation is not supported yet (upstream adds Rust support in Initial fixed-length list implementation wit-bindgen#1277, ported
    later at 0.52), so the generator arms panic with an "unsupported" message;
    no fixture exercises them.
  • Port upstream features Implement serde::Deserialize for wit-bindgen-rust::Opts wit-bindgen#1244 + Add #[serde(default)] to wit-bindgen-rust::Opts wit-bindgen#1270 (serde::Deserialize for the bindgen
    config): gate serde::Deserialize derives on Opts (serde(default, rename_all = "kebab-case")) and WithOption (rename_all = "kebab-case")
    behind a new optional serde feature, matching upstream. wRPC has neither
    ExportKey/AsyncConfig/Ownership config types nor an async_ option, so
    only Opts/WithOption apply.

Non-carries (not applicable to wRPC, dropped from the merge):

rust codegen (237) and go codegen (79) tests pass; cargo clippy --workspace
(and --features serde) and cargo doc --workspace are clean; wasmtime and all
examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0

peter-jerry-ye and others added 30 commits March 13, 2025 15:10
* fix(moonbit): string and reallocation

* fix(moonbit): unify pointer conversion

* fix(moonbit): should return charcode length

* fix(moonbit): simplify copy and fix allocation
This commit updates how bindings work for futures/streams in Rust by
ensuring that the type information for them encodes that they behave
like `own<T>` handles in that passing the value to an import for
examples passes ownership of the value in bindings. This ensures that
generates APIs appropriately model relinquishing ownership of the
`FutureReader<T>` end, for example.
Symlink the licenses from the root directory to the crates which are
publishes, so they include the license files.
Add `-Dwarnings` to the codegen tests and fixup various issues around
`unsafe` and such by shuffling around `unsafe` blocks.
…RL/repo location (#1216)

Signed-off-by: deadprogram <ron@hybridgroup.com>
* Support C# in `wit-bindgen test`

Migrate various bits of logic to the new test runner. All codegen tests
are migrated and a single "demo" program is available to show the
runtime test at least somewhat works. Migrating more tests is left to
future work.

* Add runner support for C#
* Align on naming "c-sharp" vs "csharp"

This fixes an issue where CI isn't currently running any tests for C#
because CI is using "csharp" but the `wit-bindgen test` requires
"c-sharp" because that's what `wit-bindgen`-the-CLI requires. This uses
"c-sharp" in more locations to match the CLI.

* Use `csharp` instead of `c-sharp`
This commit fully migrates the preexisting `tests/runtime/numbers` test
to the new `wit-bindgen test` framework with the only remaining guest as
C#. This is now supported and ported over meaning it now entirely
resides in the new test framework.
* Migrate `many-arguments` test to new framework

Relatively simple translation

* Remove some more files
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
* Migrate strings test to wit-bindgen test

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>

* Get new `strings` test passing

* add rust guest and drop old test

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>

* Fix typo

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>

---------

Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This is now covered by the `tests/runtime-new/demo` test which basically
does the same thing.
This hasn't been used in quite some time, so delete it.
This is a bit different from the other tests, it's mostly just a test
for Rust's behavior of the `generate!` macro.
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
This is a rust-specific test to put it in the `rust` folder and shuffle
around some definitions/things to modernize syntax (put all the WITs
into one file) and work around limitations of `wasm-compose` (no
top-level functions).
This commit extends the configuration format with a `lang` field to be
able to pass things like compiler flags. To help port one of the Rust
tests I plan on adding eventual functionality for allowing Rust tests
to specify an auxiliary file to build as a crate.
This updates async support for the Rust generator and runtime to match recent
(and not-so-recent) spec changes:

- Use explicit waitable-sets to wait for waitables
- Return packed (`CallbackCode`, waitable-set) tuples from exports and callbacks
- Remove `Event.DONE`, which no longer exists

I've tested this end-to-end with `wasip3-prototyping`.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
I messed up the name in my previous PR; this corrects it.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Previously, I had failed to consider (or test) the case where lowering values
for stream/future writes would require intermediate allocations that need to be
cleaned up.  That manifested as compiler errors due to generated code
referencing a non-existent `cleanup_list` variable.

Fixes #1153

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
* Migrate the `rust_xcrate` test to `wit-bindgen test`

This was a tricky test to migrate. Doing this required implementing a
number of new features:

* Rust now has a `[lang]`-specific configuration `externs = [...]` which
  is a list of files to compile as external crates. This tests the
  cross-crate behavior of the test.
* Tests now support more than just runner/test composed components, now
  they also support multiple components being composed. This is required
  because the test was specifically testing behavior where a component
  simultaneously imports and exports.

This last point was particularly tricky. Namely this required
abstracting the definition of a test to a runner plus a list of tests,
not just one test. These are still modeled as a list of `world` items in
the original WIT document. Additionally I was having trouble getting
`wasm-compose` working so I ended up switching to `wac`. This means that
tests can now support custom `wac` composition scripts to configure how
exactly the composition is created, and that's used in this new test to
insert a component as a sandwich between two others.

* Review comments
Pass some variables around instead of storing them on `Generator`,
removing the need to synthesize dummy values in a few contexts.
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
* Implement serde::Deserialize for wit-bindgen-rust::Opts

* Change serde to an optional dependency

* Combine serde feature attributes into a single cfg_attr line

* Run `cargo fmt`
* fix(moonbit): adjust core api

* refactor(moonbit): use internal abi

* test(moonbit): adopt new test framework

* fix(moonbit): correct bitcast behavior

* test(moonbit): more test case
alexcrichton and others added 22 commits April 14, 2025 20:10
Coupled with upstream changes to wasip3-prototyping...
This commit updates the Rust bindings generator for async to respect the
`async` annotations in WIT by default. The `--async` flag and
`async: { ... }` configuration have changed as well to be modeled as
"this is an override" where the fallback is "what the WIT says".
Use `&self` for the first argument, not `self_: ...`, by hooking into
blocks that previously were checking just for method, not also async
methods.
As the link section value can be short enough that `cargo-fmt` decides
to put it on one line, when prettyplease puts it on two, in some cases.
* fix(moonbit): Update keywords

* fix(moonbit): init and main are reserved
While `wac` is being merged upstream into `wasm-tools` fall back to
using `wasm-compose` when `wac` is not otherwise necessary. This ensures
that there's a composition tool used which is at the same version as all
the other wasm-tools tools which `wac` doesn't guarantee just yet.
This commit starts to execute some async tests in CI via artifacts
downloaded from the wasip3-prototyping repository. While the status is
reported on PRs this won't actually result in failing to merge something
if the job fails at this time since it's known that async is a bit of a
shifting landscape. In the meantime it's hoped that at least having this
status on PRs will be sufficient for seeing failures for now.

The actual set of initial tests here are relatively edge-case-y where I
added them some time ago when testing Rust bindings. They're not
comprehensive by any means but are hopefully at least a start. I hope to
next start adding more tests in follow-up PRs.
* Add some more async tests

I went through various parts of the guest runtime and sprinkled
`if true { panic!() }` throughout. Anything that wasn't hit got a test.
This led to a few issues in wasip3-prototyping:

* bytecodealliance/wasip3-prototyping#137
* bytecodealliance/wasip3-prototyping#138
* bytecodealliance/wasip3-prototyping#139
* bytecodealliance/wasip3-prototyping#140

so not all tests are fully enabled yet but they should get enabled as
bugs get fixed.

Additionally this starts to use `CALLBACK_CODE_YIELD`. That's disabled
for callbacks due to bytecodealliance/wasip3-prototyping#140 but it's
enabled for `block_on` where it translates to a `waitable-set.poll`
instead of a `waitable-set.wait`.

* Fix fallback build of `poll`

* Adjust poll signature

* Fix native signature
Upstream has now been fixed so it's possible to land this without a loop.
This commit implements async task cancellation in Rust for subtasks
created through imported calls. This involved some extra
bindings-related code to drop both lists and owned handles (effectively
a full destructor) along with some refactorings of how waitables are
handled due to new states that can pop up.
* Extract Rust's parsing of `--async` to a shared library

This should hopefully enable it to share the same parsing of this option
amongst all bindings generators.

* Implement async support in the C bindings generator

Developed through tests in this repository for now.

* Review comments
Update the name of a script after a historical rename
Update for some API changes and additionally add `todo!()` when
processing fixed-sized-lists.
* Update blocking yield signature, bind async yield

This commit updates the signature for `task_yield` and additionally
renames it to `yield_blocking`. The dual of this, `yield_async`, is also
added as a helper.

* Invert yield definition
[automatically-tag-and-release-this-commit]

Co-authored-by: Auto Release Process <auto-release-process@users.noreply.github.com>
Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree.

- Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230.
- Adapt to the wit-parser 0.230 API break: `TypeDefKind` gained a
  `FixedSizeList(Type, u32)` variant. Handle it in the introspection async-path
  walk like a `List` (element indexed by a wildcard path), and add arms to the
  Rust and Go generators' type/codec matches. Full fixed-size-list code
  generation is not supported yet (upstream adds Rust support in bytecodealliance/wit-bindgen#1277, ported
  later at 0.52), so the generator arms panic with an "unsupported" message;
  no fixture exercises them.
- Port upstream features bytecodealliance/wit-bindgen#1244 + bytecodealliance/wit-bindgen#1270 (`serde::Deserialize` for the bindgen
  config): gate `serde::Deserialize` derives on `Opts` (`serde(default,
  rename_all = "kebab-case")`) and `WithOption` (`rename_all = "kebab-case"`)
  behind a new optional `serde` feature, matching upstream. wRPC has neither
  `ExportKey`/`AsyncConfig`/`Ownership` config types nor an `async_` option, so
  only `Opts`/`WithOption` apply.

Non-carries (not applicable to wRPC, dropped from the merge):
- more `wit-bindgen test` subcommand backends (`crates/test/src/{csharp,
  moonbit}.rs`, `crates/test/LICENSE-*`) and the new `tests/runtime-async/`
  guest runtime test tree; wRPC keeps its own `wrpc-test` crate.
- the async-task / futures-stream-ABI refactors (bytecodealliance/wit-bindgen#1233/bytecodealliance/wit-bindgen#1241/bytecodealliance/wit-bindgen#1249/bytecodealliance/wit-bindgen#1260/bytecodealliance/wit-bindgen#1264/
  bytecodealliance/wit-bindgen#1268/bytecodealliance/wit-bindgen#1278/bytecodealliance/wit-bindgen#1279/bytecodealliance/wit-bindgen#1247/bytecodealliance/wit-bindgen#1240/bytecodealliance/wit-bindgen#1291/bytecodealliance/wit-bindgen#1306 etc.) and bytecodealliance/wit-bindgen#1214's canonical-ABI
  guest-code warning squashing do not apply to wRPC's transport-stub generator.

rust codegen (237) and go codegen (79) tests pass; `cargo clippy --workspace`
(and `--features serde`) and `cargo doc --workspace` are clean; wasmtime and all
examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0

@rvolosatovs rvolosatovs left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a bunch of upstream Rust wit-bindgen test additions were ignored, I'd expect to e.g. see the addition of -Dwarnings

where are all the Rust async tests?

This is too sloppy...

Comment thread crates/wit-bindgen-rust/src/lib.rs Outdated
@rvolosatovs rvolosatovs force-pushed the merge/wit-bindgen-0.42 branch from 4b236d6 to 2a39063 Compare June 23, 2026 10:33
@rvolosatovs rvolosatovs marked this pull request as ready for review June 23, 2026 10:35
@rvolosatovs rvolosatovs force-pushed the merge/wit-bindgen-0.42 branch 2 times, most recently from bd124d1 to 071299d Compare June 23, 2026 11:50
@rvolosatovs rvolosatovs merged commit 071299d into main Jun 23, 2026
38 checks passed
@rvolosatovs rvolosatovs deleted the merge/wit-bindgen-0.42 branch June 23, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants