alexcrichton opened PR #13497 from alexcrichton:implements-bindgen to bytecodealliance:main:
This commit is the next step in fleshing out #12698 and following in the footsteps of #13361 to integrate the
(implements ...)directive intobindgen!. Notably this world:world foo { import a: thing; import b: thing; }will only generate a single trait for
thing::Hostas opposed to the previous 2 traits that were generated. This enables hosts to use the same trait implementation for both, or customize as appropriate.Additionally the
add_to_linker-generated methods for interfaces are now refactored to additionally have anadd_to_linker_instanceentrypoint. This new entrypoint takes aLinkerInstanceinstead of aLinkerand fills in the provided instance directly. This is in-turn used to fill out a linker for thefooworld above.Notably, however, embedders can call
add_to_linker_instancewith distinct closures accessing different parts ofT, the store's state, meaning that it's possible to have two distinct implementations foraandbabove.Many golden tests were updated with this new
add_to_linker_instancemethod, and codegen/runtime tests were added for a simple world as well showcasing the bindings modes that are possible. The (rarely used) top-level worldadd_to_linkeronly uses a single trait implementation, but invokingadd_to_linker_instanceenables passing in two separate implementations.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested dicej for a review on PR #13497.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13497.
:thumbs_up: dicej submitted PR review.
:speech_balloon: dicej created PR review comment:
Would it be valuable to add a test here that verifies that
getand/orsetcalls by the guest are directed to the correct caches, i.e. add a runtime test with a non-dummy component in addition to the instantiation tests?
:speech_balloon: dicej created PR review comment:
Suggestion: add
crates/component-macro/tests/expanded/** linguist-generated=trueto.gitattributesto hide these generated files in diffs by default.
alexcrichton requested fitzgen for a review on PR #13497.
alexcrichton updated PR #13497.
alexcrichton requested wasmtime-default-reviewers for a review on PR #13497.
alexcrichton has enabled auto merge for PR #13497.
alexcrichton added PR #13497 Loosely integrate implements into bindgen! to the merge queue
:check: alexcrichton merged PR #13497.
alexcrichton removed PR #13497 Loosely integrate implements into bindgen! from the merge queue
Last updated: Jun 01 2026 at 09:49 UTC