futures-await icon indicating copy to clipboard operation
futures-await copied to clipboard

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

Open shisoft opened this issue 6 years ago • 13 comments

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

shisoft avatar Jun 29 '18 14:06 shisoft

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

lnicola avatar Jul 03 '18 05:07 lnicola

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

lnicola avatar Jul 17 '18 13:07 lnicola

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.

Nemo157 avatar Jul 17 '18 15:07 Nemo157

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.

lnicola avatar Jul 17 '18 15:07 lnicola

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_!.

withoutboats avatar Jul 17 '18 15:07 withoutboats

A temporary workaround:

$ rustup override set nightly-2018-07-10
$ cargo update -p proc-macro2:0.4.8 --precise 0.4.6

realcr avatar Jul 17 '18 16:07 realcr

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 avatar Jul 17 '18 16:07 withoutboats

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

withoutboats avatar Jul 17 '18 16:07 withoutboats

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

realcr avatar Jul 17 '18 16:07 realcr

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

lnicola avatar Jul 17 '18 19:07 lnicola

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)

rubdos avatar Jul 20 '18 09:07 rubdos

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)

xxks-kkk avatar Oct 23 '18 19:10 xxks-kkk

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

withoutboats avatar Oct 24 '18 12:10 withoutboats