Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pimeys opened this issue Mar 21, 2025 · 2 comments
Open

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

pimeys opened this issue Mar 21, 2025 · 2 comments
Assignees
Labels
bug Incorrect behavior in the current implementation that needs fixing

Comments

@pimeys
Copy link

pimeys commented Mar 21, 2025

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

@pimeys pimeys added the bug Incorrect behavior in the current implementation that needs fixing label Mar 21, 2025
@pimeys
Copy link
Author

pimeys commented Mar 21, 2025

This looks like the source of the issue:

#10311

Ping @pchickey

@pchickey
Copy link
Contributor

Thanks for the bug report - will look into this soon

@pchickey pchickey self-assigned this Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior in the current implementation that needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants