Skip to content

wai-bindgen-rust does not compile: error[E0277]: RefCell<State> cannot be shared between threads safely #43

@wellcaffeinated

Description

@wellcaffeinated

Hi there. I'm getting the following error when trying to compile my wapm package with the command:

RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' \
    rustup run nightly-2023-05-31 \
    cargo build --target wasm32-wasi --release
   Compiling wai-bindgen-rust v0.2.3
error[E0277]: `RefCell<State>` cannot be shared between threads safely
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:72:34
   |
72 |         let waker = self.clone().into();
   |                                  ^^^^ `RefCell<State>` cannot be shared between threads safely
   |
   = help: within `PollingWaker`, the trait `Sync` is not implemented for `RefCell<State>`
   = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead
note: required because it appears within the type `PollingWaker`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:22:8
   |
22 | struct PollingWaker {
   |        ^^^^^^^^^^^^
   = note: required for `std::task::Waker` to implement `From<Arc<PollingWaker>>`
   = note: required for `Arc<PollingWaker>` to implement `Into<std::task::Waker>`

error[E0277]: `(dyn Future<Output = ()> + 'static)` cannot be sent between threads safely
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:72:34
   |
72 |         let waker = self.clone().into();
   |                                  ^^^^ `(dyn Future<Output = ()> + 'static)` cannot be sent between threads safely
   |
   = help: the trait `Send` is not implemented for `(dyn Future<Output = ()> + 'static)`
   = note: required for `Unique<(dyn Future<Output = ()> + 'static)>` to implement `Send`
note: required because it appears within the type `Box<dyn Future<Output = ()>>`
  --> /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/alloc/src/boxed.rs:195:12
note: required because it appears within the type `Pin<Box<dyn Future<Output = ()>>>`
  --> /rustc/f0411ffcebcd7f75ac02ed45feb53ffd07b75398/library/core/src/pin.rs:410:12
note: required because it appears within the type `State`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:26:6
   |
26 | enum State {
   |      ^^^^^
   = note: required for `RefCell<State>` to implement `Send`
note: required because it appears within the type `PollingWaker`
  --> /Users/wellcaffeinated/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wai-bindgen-rust-0.2.3/src/futures.rs:22:8
   |
22 | struct PollingWaker {
   |        ^^^^^^^^^^^^
   = note: required for `std::task::Waker` to implement `From<Arc<PollingWaker>>`
   = note: required for `Arc<PollingWaker>` to implement `Into<std::task::Waker>`

For more information about this error, try `rustc --explain E0277`.

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