Skip to content

wit-bindgen panics on import + async + sized lists #1744

Open

Description

@swankjesse

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions