Lstarsky0 opened PR #14150 from Lstarsky0:fix/c-api-declare-vecs-cfg to bytecodealliance:main:
cargo check -p wasmtime-c-api --no-default-features --features component-modelfails on main with 23 diagnostics, starting with:error[E0433]: cannot find `declare_vecs` in `crate` error[E0425]: cannot find type `wasmtime_component_vallist_t` in this scope ...What is broken
crates/c-api/src/component/val.rs:11callscrate::declare_vecs!.declare_vecsis a plainmacro_rules!, so that path only resolves because of the re-export at the bottom ofvec.rs— and the re-export is gated on the wrong feature:#[cfg(feature = "async")] pub(crate) use declare_vecs;
component/val.rsis behind#[cfg(feature = "component-model")](lib.rs:104), andcomponent-modeldoes not implyasync. Enable one without the other and the macro is not in scope, taking every vec type it declares with it.
crate::declare_vecs!has exactly one caller,component/val.rs. Nothing underasyncuses the path form.How it got here
#10697added the re-export for this consumer with no cfg at all:+pub(crate) use declare_vecs;
4f2fa1541("Update nightly Rust used in CI") later added the#[cfg(feature = "async")]line — the shape of a fix for an unused-import warning from a newer lint, with the feature picked incorrectly.CI did not catch it because the
wasmtime-c-apimatrix entry covers--no-default-featuresand thenwat,wasiandgc.component-modelalone was never built.The change
One line: the re-export is gated on
component-model, matching its only consumer.Testing
Feature matrix for
wasmtime-c-api-impl, before and after:
features main with this PR component-model24 errors ok component-model,asyncok ok asyncok ok component-model,cranelift24 errors ok none, wat,wasi,gcok ok
-p wasmtime-c-api --no-default-features --features component-modelis added to thewasmtime-c-apichecks. It fails on unpatched main with 23 diagnostics and passes here.Also clean, run twice: the four existing
wasmtime-c-apichecks,-p wasmtime-c-api-impl --all-features,cargo clippy -p wasmtime-c-api-impl --no-default-features --features component-model,cargo test -p wasmtime-c-api-impl,cargo fmt --all -- --check.One warning remains under
component-model—unused import: wasm_byte_vec_tincomponent/component.rs. It is already there on main undercomponent-model,async, so it is not from this change and I have left it alone.
Lstarsky0 requested wasmtime-core-reviewers for a review on PR #14150.
Lstarsky0 requested pchickey for a review on PR #14150.
Lstarsky0 requested fitzgen for a review on PR #14150.
Lstarsky0 requested wasmtime-default-reviewers for a review on PR #14150.
Lstarsky0 updated PR #14150.
Lstarsky0 edited PR #14150:
cargo check -p wasmtime-c-api --no-default-features --features component-modelfails on main with 23 diagnostics, starting with:error[E0433]: cannot find `declare_vecs` in `crate` error[E0425]: cannot find type `wasmtime_component_vallist_t` in this scope ...What is broken
crates/c-api/src/component/val.rs:11callscrate::declare_vecs!.declare_vecsis a plainmacro_rules!, so that path only resolves because of the re-export at the bottom ofvec.rs— and the re-export is gated on the wrong feature:#[cfg(feature = "async")] pub(crate) use declare_vecs;
component/val.rsis behind#[cfg(feature = "component-model")](lib.rs:104), andcomponent-modeldoes not implyasync. Enable one without the other and the macro is not in scope, taking every vec type it declares with it.
crate::declare_vecs!has exactly one caller,component/val.rs. Nothing underasyncuses the path form.How it got here
#10697added the re-export for this consumer with no cfg at all:+pub(crate) use declare_vecs;
4f2fa1541("Update nightly Rust used in CI") later added the#[cfg(feature = "async")]line — the shape of a fix for an unused-import warning from a newer lint, with the feature picked incorrectly.CI did not catch it because the
wasmtime-c-apimatrix entry covers--no-default-featuresand thenwat,wasiandgc.component-modelalone was never built.The change
One line: the re-export is gated on
component-model, matching its only consumer.Testing
Feature matrix for
wasmtime-c-api-impl, before and after:
features main with this PR component-model24 errors ok component-model,asyncok ok asyncok ok component-model,cranelift24 errors ok none, wat,wasi,gcok ok
-p wasmtime-c-api --no-default-features --features component-modelis added to thewasmtime-c-apichecks. It fails on unpatched main with 23 diagnostics and passes here.Also clean, run twice: the four existing
wasmtime-c-apichecks,-p wasmtime-c-api-impl --all-features,cargo clippy -p wasmtime-c-api-impl --no-default-features --features component-model,cargo test -p wasmtime-c-api-impl,cargo fmt --all -- --check.One more thing had to come with it.
component/component.rsimportswasm_byte_vec_tunconditionally, but the only use is inwasmtime_component_serialize, which is gated oncraneliftorwinch. Undercomponent-modelalone the import is unused, and CI runs withRUSTFLAGS=-D warnings, so the new check fails on it. The import is now gated the same way as its use.The warning is not from this change — it is on main today under
component-model,asyncas well. Nothing built either configuration, which is why it had never surfaced. I first pushed this without the import fix and CI caught it, which is the check doing its job.
:thumbs_up: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
No need for comments here, the
#[cfg]explains things.
:speech_balloon: alexcrichton created PR review comment:
Should this be
any(feature = "async", feature = "component-model")?
alexcrichton unassigned pchickey from PR #14150 c-api: fix the component-model build without async.
alexcrichton requested alexcrichton for a review on PR #14150.
alexcrichton unassigned fitzgen from PR #14150 c-api: fix the component-model build without async.
alexcrichton commented on PR #14150:
Also, please be sure to review our AI tool usage policy
Lstarsky0 updated PR #14150.
:memo: Lstarsky0 submitted PR review.
:speech_balloon: Lstarsky0 created PR review comment:
Dropped. The import order moves in the same commit: the comment was what kept rustfmt from sorting those two use lines, so cargo fmt --check fails once it is gone
:memo: Lstarsky0 submitted PR review.
:speech_balloon: Lstarsky0 created PR review comment:
No, that breaks async on its own. crate::declare_vecs! has one caller, component/val.rs:11, and mod component is gated on component-model at lib.rs:104, so under --features async with no component-model nothing uses the path form and the re-export is unused. With -D warnings that is error: unused import: declare_vecs at vec.rs:152. That is the same warning the original #[cfg(feature = "async")] was silencing. It named the wrong feature, which is what let component-model alone break
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #14150 c-api: fix the component-model build without async to the merge queue.
:check: alexcrichton merged PR #14150.
alexcrichton removed PR #14150 c-api: fix the component-model build without async from the merge queue.
Last updated: Aug 30 2026 at 09:07 UTC