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

Compiling for wasm32-unknown-unknown fails inside event-listener-strategy #50

Closed
Ekleog opened this issue Jan 23, 2024 · 4 comments · Fixed by #61
Closed

Compiling for wasm32-unknown-unknown fails inside event-listener-strategy #50

Ekleog opened this issue Jan 23, 2024 · 4 comments · Fixed by #61

Comments

@Ekleog
Copy link

Ekleog commented Jan 23, 2024

The error message looks like:

error[E0599]: no method named `wait` found for struct `Pin<&'evl mut EventListener>` in the current scope
   --> /home/ekleog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/event-listener-strategy-0.1.0/src/lib.rs:479:13
    |
479 |         evl.wait();
    |             ^^^^ method not found in `Pin<&mut EventListener>`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following traits define an item `wait`, perhaps you need to implement one of them:
            candidate #1: `EventListenerFuture`
            candidate #2: `Strategy`

I'm currently looking for a workaround, because event-listener definitely seems to support wasm32-unknown-unknown. But currently my only idea, aka default_features = false, features = ["portable-atomic"] is without any success.

My current status is this crate, initialized with cargo init --bin and with only the Cargo.toml modified this way, built with cargo build --target=wasm32-unknown-unknown:

[package]
name = "foobar"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-broadcast = "0.6.0"
event-listener = { version = "3.0", default-features = false, features = ["portable-atomic"] }

I have also tried with the latest rust nightly without success, to make it less likely it's a bug in the specific nightly I had pinned.

Incidentally, it looks like event-listener released a v4 and event-listener-strategy released a v0.4, it might be worth updating async-broadcast?

I'm open to any ideas, and will continue searching on my side :)

@Ekleog
Copy link
Author

Ekleog commented Jan 23, 2024

Seems like bumping the dependencies fixes the issue, see #51 for a suggested fix (disclaimer: I have no idea what I'm doing, I just fiddled until things built and checked that the added #[cfg] was reasonable enough :))

@lf-wxp
Copy link

lf-wxp commented Feb 10, 2024

in version 0.7.0, seems have the familiar issue, even though event-listener is 5.0 and event-listener-strategy is 0.5.

error[E0599]: no method named `wait` found for struct `SendInner` in the current scope
    --> /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-broadcast-0.7.0/src/lib.rs:1595:1
     |
1595 | / easy_wrapper! {
1596 | |     /// A future returned by [`Sender::broadcast()`].
1597 | |     #[derive(Debug)]
1598 | |     #[must_use = "futures do nothing unless .awaited"]
1599 | |     pub struct Send<'a, T: Clone>(SendInner<'a, T> => Result<Option<T>, SendError<T>>);
1600 | |     pub(crate) wait();
1601 | | }
     | |_^ method not found in `SendInner<'_, T>`
1602 |
1603 | / pin_project! {
1604 | |     #[derive(Debug)]
1605 | |     struct SendInner<'a, T> {
1606 | |         sender: &'a Sender<T>,
...    |
1613 | |     }
1614 | | }
     | |_- method `wait` not found for this struct
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `wait`, perhaps you need to implement it:
             candidate #1: `Strategy`
     = note: this error originates in the macro `easy_wrapper` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `wait` found for struct `RecvInner` in the current scope
    --> /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-broadcast-0.7.0/src/lib.rs:1667:1
     |
1667 | / easy_wrapper! {
1668 | |     /// A future returned by [`Receiver::recv()`].
1669 | |     #[derive(Debug)]
1670 | |     #[must_use = "futures do nothing unless .awaited"]
1671 | |     pub struct Recv<'a, T: Clone>(RecvInner<'a, T> => Result<T, RecvError>);
1672 | |     pub(crate) wait();
1673 | | }
     | |_^ method not found in `RecvInner<'_, T>`
1674 |
1675 | / pin_project! {
1676 | |     #[derive(Debug)]
1677 | |     struct RecvInner<'a, T> {
1678 | |         receiver: &'a mut Receiver<T>,
...    |
1684 | |     }
1685 | | }
     | |_- method `wait` not found for this struct
`

@zeenix
Copy link
Member

zeenix commented Feb 28, 2024

Is this still valid with the latest release?

@lf-wxp
Copy link

lf-wxp commented Feb 29, 2024

Here is the code. https://github.com/lf-wxp/rust-practice/tree/main/yew-await

in version 0.7.0, seems have the familiar issue, even though event-listener is 5.0 and event-listener-strategy is 0.5.

error[E0599]: no method named `wait` found for struct `SendInner` in the current scope
    --> /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-broadcast-0.7.0/src/lib.rs:1595:1
     |
1595 | / easy_wrapper! {
1596 | |     /// A future returned by [`Sender::broadcast()`].
1597 | |     #[derive(Debug)]
1598 | |     #[must_use = "futures do nothing unless .awaited"]
1599 | |     pub struct Send<'a, T: Clone>(SendInner<'a, T> => Result<Option<T>, SendError<T>>);
1600 | |     pub(crate) wait();
1601 | | }
     | |_^ method not found in `SendInner<'_, T>`
1602 |
1603 | / pin_project! {
1604 | |     #[derive(Debug)]
1605 | |     struct SendInner<'a, T> {
1606 | |         sender: &'a Sender<T>,
...    |
1613 | |     }
1614 | | }
     | |_- method `wait` not found for this struct
     |
     = help: items from traits can only be used if the trait is implemented and in scope
     = note: the following trait defines an item `wait`, perhaps you need to implement it:
             candidate #1: `Strategy`
     = note: this error originates in the macro `easy_wrapper` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `wait` found for struct `RecvInner` in the current scope
    --> /Users/xxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-broadcast-0.7.0/src/lib.rs:1667:1
     |
1667 | / easy_wrapper! {
1668 | |     /// A future returned by [`Receiver::recv()`].
1669 | |     #[derive(Debug)]
1670 | |     #[must_use = "futures do nothing unless .awaited"]
1671 | |     pub struct Recv<'a, T: Clone>(RecvInner<'a, T> => Result<T, RecvError>);
1672 | |     pub(crate) wait();
1673 | | }
     | |_^ method not found in `RecvInner<'_, T>`
1674 |
1675 | / pin_project! {
1676 | |     #[derive(Debug)]
1677 | |     struct RecvInner<'a, T> {
1678 | |         receiver: &'a mut Receiver<T>,
...    |
1684 | |     }
1685 | | }
     | |_- method `wait` not found for this struct
`

@zeenix zeenix closed this as completed in #61 Jun 8, 2024
zeenix pushed a commit that referenced this issue Jun 8, 2024
Fixes #50

I dont really know if this is correct since I didnt dig too deep into
the issue but it does compile and work for me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants