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

Ouverte
#1,744 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
67/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust, wasm
Domaine
backend

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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!

Langage dominant
Rust
Étoiles
1.5k
Forks
306
Merge moyen
1 j 4 h
PR mergées (30 j)
21

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

  • Aucun Dockerfile ni fichier Docker Compose
  • Aucun modèle de pull request
  • Aucun guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de bytecodealliance/wit-bindgen

Toutes les issues de bytecodealliance/wit-bindgen

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.