wit-bindgen panics on `import` + `async` + sized lists

Aberta
#1,744 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
67/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
rust, wasm
Domínio
backend

Direção de pesquisa

Start by reproducing the panic with the .wit declaration and Rust guest example in the issue, using wit-bindgen 0.62.0 and the shown wasm32-wasip2 cargo build command. Trace the wit_bindgen::generate! path for imported async functions with sized list parameters and compare it with the unsized-list workaround. Done when the macro generates bindings and the example compiles.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

I continue hacking on Brevity and ran into a case where wit-bindgen’s Rust macro panics.

Here’s a little .wit declaration that imports an async function that accepts a sized list as a parameter.

package brevity:testing;

world brevity-test {
  import import-sized-list: async func(v: list<bool,2>) -> s32;
  export export-sized-list: async func(v: list<bool>) -> s32;
}

Here’s Rust that implements the guest side:

#![allow(unused_imports)]
use std::thread::sleep;
use std::time::Duration;

mod bindings {
    wit_bindgen::generate!({
        path: "./wit/sizedlists.wit",
    });

    use super::BrevityTesting;
    export!(BrevityTesting);
}

struct BrevityTesting;

impl bindings::Guest for BrevityTesting {
  async fn export_sized_list(_v: Vec<bool>) -> i32 {
    0
  }
}

Here’s the obvious cargo.toml:

[package]
name = "brevity-testing-sizedLists"
version = "0.1.0"
edition = "2024"

[dependencies]
wit-bindgen = "0.62.0"

[lib]
path = "src/sizedLists_lib.rs"
crate-type = ['cdylib']
Expected

Program compiles

Actual

Macro panics.

$ cargo build --target=wasm32-wasip2 --release
   Compiling brevity-testing-sizedLists v0.1.0 (/Volumes/Development/brevity/brevity-integration-tests/build/BrevityExecutionTester/sizedLists/rust)
error: proc macro panicked
 --> src/sizedLists_lib.rs:6:5
  |
6 | /     wit_bindgen::generate!({
7 | |         path: "./wit/sizedlists.wit",
8 | |     });
  | |______^
  |
  = help: message: not yet implemented

error: cannot find macro `export` in this scope
  --> src/sizedLists_lib.rs:11:5
   |
11 |     export!(BrevityTesting);
   |     ^^^^^^

error[E0405]: cannot find trait `Guest` in module `bindings`
  --> src/sizedLists_lib.rs:16:16
   |
16 | impl bindings::Guest for BrevityTesting {
   |                ^^^^^ not found in `bindings`

For more information about this error, try `rustc --explain E0405`.
error: could not compile `brevity-testing-sizedLists` (lib) due to 3 previous errors

Work-around by editing the wit to not use a sized list.

   package brevity:testing;

   world brevity-test {
-    import import-sized-list: async func(v: list<bool,2>) -> s32;
+    import import-sized-list: async func(v: list<bool>) -> s32;
     export export-sized-list: async func(v: list<bool>) -> s32;
   }

This isn’t blocking us. Thanks!

Linguagem predominante
Rust
Estrelas
1.5k
Forks
306
Merge médio
1d 4h
PRs com merge (30d)
21

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

  • Sem Dockerfile nem arquivo Docker Compose
  • Sem modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de bytecodealliance/wit-bindgen

Todas as issues de bytecodealliance/wit-bindgen

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.