Skip to content

wasmtime::component::bindgen! macro generates invalid code #10449

Closed
@pimeys

Description

@pimeys

Test Case

In our repository, we have versioned wit shared by our host and guest code. One of the bindgen calls started generating invalid Rust code when we updated wasmtime from version 30 to version 31:

https://github.com/grafbase/grafbase/blob/renovate/wasmtime/crates/wasi-component-loader/src/extension/api/since_0_8_0/wit.rs

Then again the next version of this wit, which is just reorganized and a few things are changed in the method calls, this generates correct code:

https://github.com/grafbase/grafbase/blob/renovate/wasmtime/crates/wasi-component-loader/src/extension/api/since_0_9_0/wit.rs

Steps to Reproduce

  • Clone repo https://github.com/grafbase/grafbase
  • Compile the crate crates/wasi-component-loader with cargo build, it should work.
  • Change the branch to renovate/wasmtime which updates wasmtime from 30 to 31
  • See the bindgen macro giving an error: use of undeclared lifetime name 'a

Expected Results

Updating wasmtime should not lead to invalid Rust code.

Actual Results

If you expand the macro with an error, we see code like this generated:

pub type DirectiveSite = super::super::super::__with_name0::DirectiveSite<'a>;
pub type FieldDefinitionDirective = super::super::super::__with_name0::FieldDefinitionDirective<'a>;

The 0.9.0 wit macro does not generate code like this, nor does wasmtime 30 for the exact same macro call.

Versions and Environment

Wasmtime: 31.0.0
Operating system: Aurora Linux
Architecture: x86_64

Metadata

Metadata

Assignees

Labels

bugIncorrect behavior in the current implementation that needs fixingwasm-proposal:component-modelIssues related to the WebAssembly Component Model proposal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions