Hi, I'm not sure if this is intended, but giving the follow snippet, the compiler will "no Foo in my::test::test" unless the test-fn is uncommented. And this only applies to variant but not enum.
wit_bindgen::generate!({
inline: r"
package my:test;
interface test {
variant foo {
a,
}
enum bar {
a,
}
/// test-fn: func(val: foo);
}
world the-world {
import test;
}
",
});
use my::test::test::Bar;
use my::test::test::Foo;
This is expected, but if you don't want this behavior you can pass generate_unused_types: true to the macro (documented here)
Thank you Alex, as always. How could I miss the obvious setting, and was also looking at the wrong docs at wasmtime/component/bindgen.
Edit: Looks like the option works only for the guest(wit-bindgen), but not the host(wasmtime::component::bindgen).
It's true yeah the two codebases have diverged over time and while we try to keep them similar they aren't the exact same
Last updated: Dec 06 2025 at 07:03 UTC