alexcrichton / futures-await

Apache License 2.0
734 stars 55 forks source link

`await` is ambiguous after updated to nightly-2018-06-24 and after #106

Open shisoft opened 6 years ago

shisoft commented 6 years ago

Hi, It seems like the nightly rust have already built in await macro which conflict with this crate. Is there any suggestion to resolve this problem before futures 0.3 was settled?

Thanks

error[E0659]: await is ambiguous --> src/raft/client.rs:152:5 152 #[async(boxed)] ^^^^^^^^^^^^^^^

note: await could refer to the name imported here --> src/raft/client.rs:20:5 | 20 | use futures::prelude::*; | ^^^^^^^^^^^^^^^^^^^ = note: await is also a builtin macro = note: consider adding an explicit import of await to disambiguate

lnicola commented 6 years ago

Can you try use futures::prelude::{async, await}; instead?

lnicola commented 6 years ago

Well, that doesn't seem to be working any more.

Nemo157 commented 6 years ago

Just to make sure everyone coming here is aware, this is an incompatibility with the new builtin async/await support. I would have expected @lnicola's suggestion to work, but maybe there's some weird interaction between the implicit #[macro_use] extern crate std; and the use_extern_macro feature.

lnicola commented 6 years ago

It was working, but I updated today and now I'm getting:

error[E0658]: macro await! is unstable (see issue #50547)
   --> src/main.rs:111:20
    |
111 |     let mut file = await!(tokio::fs::File::open(path.clone()))?;
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(await_macro)] to the crate attributes to enable

Probably related to the proc-macro2 changes.

withoutboats commented 6 years ago

I would've thought they would be shadowed, but I guess that's not happening for some unclear reason. Only way I know to fix this would be to release a new version with this macro renamed to something like await_!.

realcr commented 6 years ago

A temporary workaround:

$ rustup override set nightly-2018-07-10
$ cargo update -p proc-macro2:0.4.8 --precise 0.4.6
withoutboats commented 6 years ago

Alex Crichton informs me that adding the use_extern_crate feature to your #![features()] list may, in the most recent nightly, make @lnicola's solution work.

withoutboats commented 6 years ago

Sorry, the feature is called use_extern_macros not use_extern_crate, I am sort of sleep deprived

realcr commented 6 years ago

@withoutboats : Thank you! I will try it out. Go get some sleep, our future async world depends on you (:

lnicola commented 6 years ago

Yes, adding #![feature(use_extern_macros)] seems to work.

rubdos commented 6 years ago

Well, that doesn't seem to be working any more.

#![feature(use_extern_macros)]

(edit: Github was bugging, I didn't see the other comments and I cannot delete this one)

xxks-kkk commented 5 years ago

I tried the solution above, now I got

error[E0627]: yield statement outside of generator literal
   --> /home/zeyuanhu/rustfs/spdk-rs/src/bdev.rs:119:19
    |
119 |         let res = await!(receiver).expect("Cancellation is not supported");
    |                   ^^^^^^^^^^^^^^^^
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

My rustc version rustc 1.31.0-nightly (b2d6ea98b 2018-10-07)

withoutboats commented 5 years ago

@xxks-kkk are you calling await inside of a function tagged #[async]?