Logicalshift / desync

Hassle-free asynchronous programming for Rust
https://docs.rs/desync
Apache License 2.0
31 stars 4 forks source link

Issue Compiling after Rustup Update #12

Closed andrewexton373 closed 1 year ago

andrewexton373 commented 1 year ago

Hello,

I apologize if this is the wrong place to ask, however after revisiting a project from last year I ran into some compilation issues. After running a rustup update, my project is failing to compile and this crate seems to be the root issue based off the Error messages I'm receiving. Let me know if you have any thoughts or could point me in the right direction on where to ask to get help resolving the issue, thanks! I appreciate your time and contributions :)

 Compiling desync v0.8.1                                                                                                                                 
     Running `rustc --crate-name desync --edition=2018 C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\desync-0.8.1\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=154 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C metadata=9966a1dedf79bfc2 -C extra-filename=-9966a1dedf79bfc2 --out-dir C:\Users\andre\Development\geometry-wars\target\debug\deps -L dependency=C:\Users\andre\Development\geometry-wars\target\debug\deps --extern futures=C:\Users\andre\Development\geometry-wars\target\debug\deps\libfutures-7aecd002f6e66d59.rmeta --extern lazy_static=C:\Users\andre\Development\geometry-wars\target\debug\deps\liblazy_static-7374f8c73ace3fd0.rmeta --extern num_cpus=C:\Users\andre\Development\geometry-wars\target\debug\deps\libnum_cpus-b25f9abc8452ef67.rmeta --cap-lints allow`
error: future cannot be sent between threads safely                                                                                                        
   --> C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\desync-0.8.1\src\pipe.rs:105:28
    |
105 |             let _ = target.future_desync(move |core| {
    |                            ^^^^^^^^^^^^^ future created by async block is not `Send`
    |
    = help: within `[async block@C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\desync-0.8.1\src\pipe.rs:106:17: 125:18]`, the trait `std::marker::Send` is not implemented for `*mut ()`
note: future is not `Send` as this value is used across an await
   --> C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\desync-0.8.1\src\pipe.rs:119:58
    |
109 |                     let context = Context::from_waker(&waker);
    |                         ------- has type `Context<'_>` which is not `Send`
...
119 |                         let keep_polling    = future_poll.await;
    |                                                          ^^^^^^ await occurs here, with `context` maybe used later
...
125 |                 }
    |                 - `context` is later dropped here
note: required by a bound in `desync::Desync::<T>::future_desync`
   --> C:\Users\andre\.cargo\registry\src\index.crates.io-6f17d22bba15001f\desync-0.8.1\src\desync.rs:171:34
    |
168 |     pub fn future_desync<'a, TFn, TFuture>(&self, job: TFn) -> SchedulerFuture<TFuture::Output>
    |            ------------- required by a bound in this associated function
...
171 |         TFuture:            'a + Send + Future,
    |                                  ^^^^ required by this bound in `Desync::<T>::future_desync`
Logicalshift commented 1 year ago

Yep, this started failing for me just recently, I think probably due to a rust bugfix. Working on a fix at the moment, not entirely sure how the code ended up like this (it was a while ago, and by the looks of the issue it was probably confusion when rewriting from the old style of futures to the newer async style)

It's actually pretty surprising that this ever compiled to me.

Logicalshift commented 1 year ago

I've released new versions of desync v0.7 and v0.8 that fix this issue.

andrewexton373 commented 1 year ago

Just tried again and everything compiled perfectly, you rock! Thanks for your assistance!