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

Removed std::r#await macro causes compilation fail #1087

Closed
Empty2k12 opened this issue May 12, 2019 · 4 comments
Closed

Removed std::r#await macro causes compilation fail #1087

Empty2k12 opened this issue May 12, 2019 · 4 comments

Comments

@Empty2k12
Copy link

Version

❯ cargo tree | rg tokio
    Updating crates.io index
├── tokio v0.1.19
│   ├── tokio-async-await v0.1.7
│   │   └── tokio-io v0.1.12
│   ├── tokio-codec v0.1.1
│   │   └── tokio-io v0.1.12 (*)
│   ├── tokio-current-thread v0.1.6
│   │   └── tokio-executor v0.1.7
│   ├── tokio-executor v0.1.7 (*)
│   ├── tokio-fs v0.1.6
│   │   ├── tokio-io v0.1.12 (*)
│   │   └── tokio-threadpool v0.1.14
│   │       └── tokio-executor v0.1.7 (*)
│   │   └── tokio-io v0.1.12 (*)
│   ├── tokio-io v0.1.12 (*)
│   ├── tokio-reactor v0.1.9
│   │   ├── tokio-executor v0.1.7 (*)
│   │   ├── tokio-io v0.1.12 (*)
│   │   └── tokio-sync v0.1.5
│   ├── tokio-sync v0.1.5 (*)
│   ├── tokio-tcp v0.1.3
│   │   ├── tokio-io v0.1.12 (*)
│   │   └── tokio-reactor v0.1.9 (*)
│   ├── tokio-threadpool v0.1.14 (*)
│   ├── tokio-timer v0.2.10
│   │   └── tokio-executor v0.1.7 (*)
│   ├── tokio-trace-core v0.1.0
│   ├── tokio-udp v0.1.3
│   │   ├── tokio-codec v0.1.1 (*)
│   │   ├── tokio-io v0.1.12 (*)
│   │   └── tokio-reactor v0.1.9 (*)
│   └── tokio-uds v0.2.5
│       ├── tokio-codec v0.1.1 (*)
│       ├── tokio-io v0.1.12 (*)
│       └── tokio-reactor v0.1.9 (*)
    ├── tokio v0.1.19 (*)
    └── tokio-async-await v0.1.7 (*)

Platform

Darwin 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:49:07 PDT 2019; root:xnu-4903.261.4~4/RELEASE_X86_64 x86_64

Subcrates

tokio-futures

Description

Running with latest nightly, the compilation of tokio-async-await fails, as the std::r#await macro which is being rexported has been deleted in this commit: rust-lang/rust#60675.

I expected to see this happen:

   Compiling my-bin v0.1.0 (/Users/gero/dev/my-bin)
    Finished dev [unoptimized + debuginfo] target(s) in 4.29s
     Running `target/debug/my-bin`

Instead, this happened:

   Compiling tokio-async-await v0.1.7
error[E0432]: unresolved import `std::await`
  --> /Users/gero/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-async-await-0.1.7/src/lib.rs:35:9
   |
35 | pub use std::await as std_await;
   |         ^^^^^^^^^^^^^^^^^^^^^^^ no `await` in the root

-->

@sdroege
Copy link
Contributor

sdroege commented May 13, 2019

I locally worked around this with the following change. It's enough for getting my code to run (using the futures 0.3 -> 0.1 conversions), but the async/await examples in tokio are failing to compile. That's why I didn't send a PR.

diff --git a/tokio-futures/src/await.rs b/tokio-futures/src/await.rs
index 1e8f6e7..c357539 100644
--- a/tokio-futures/src/await.rs
+++ b/tokio-futures/src/await.rs
@@ -1,16 +1,15 @@
 /// Wait for a future to complete.
 #[macro_export]
-macro_rules! await {
+macro_rules! r#await {
     ($e:expr) => {{
         #[allow(unused_imports)]
         use $crate::compat::backward::IntoAwaitable as IntoAwaitableBackward;
         #[allow(unused_imports)]
         use $crate::compat::forward::IntoAwaitable as IntoAwaitableForward;
-        use $crate::std_await;
 
         #[allow(unused_mut)]
         let mut e = $e;
         let e = e.into_awaitable();
-        std_await!(e)
+        e.await
     }};
 }
diff --git a/tokio-futures/src/lib.rs b/tokio-futures/src/lib.rs
index 411dc42..fdf709d 100644
--- a/tokio-futures/src/lib.rs
+++ b/tokio-futures/src/lib.rs
@@ -28,8 +28,3 @@ pub mod compat;
 pub mod io;
 pub mod sink;
 pub mod stream;
-
-// Rename the `await` macro in `std`. This is used by the redefined
-// `await` macro in this crate.
-#[doc(hidden)]
-pub use std::await as std_await;
diff --git a/tokio/src/lib.rs b/tokio/src/lib.rs
index 872f23c..8b89a83 100644
--- a/tokio/src/lib.rs
+++ b/tokio/src/lib.rs
@@ -1,5 +1,5 @@
 #![doc(html_root_url = "https://docs.rs/tokio/0.1.19")]
-#![deny(missing_docs, warnings, missing_debug_implementations)]
+#![deny(missing_docs, missing_debug_implementations)]
 #![cfg_attr(feature = "async-await-preview", feature(async_await, await_macro))]
 
 //! A runtime for writing reliable, asynchronous, and slim applications.

@taiki-e
Copy link
Member

taiki-e commented May 13, 2019

See also #1080 and #1082.

@carllerche
Copy link
Member

Thanks for the report. Progress is ongoing to address the issue (see above).

However, the fixes will not be applied to the 0.1 branch. For the immediate future, to track the latest async / await changes with Tokio, using the version off of the git master branch will be required.

@sdroege
Copy link
Contributor

sdroege commented May 14, 2019

For the time being, https://rust-lang-nursery.github.io/futures-api-docs/0.3.0-alpha.16/futures/compat/index.html might be useful then, and removing the translation layer from tokio 0.1 to prevent confusion.

trezm added a commit to thruster-rs/Thruster that referenced this issue May 15, 2019
**Note:** Also had to switch to tokio master thanks to [this](tokio-rs/tokio#1087 (comment)).
trezm added a commit to thruster-rs/Thruster that referenced this issue May 15, 2019
**Note:** Also had to switch to tokio master thanks to [this](tokio-rs/tokio#1087 (comment)).
mokomull added a commit to mokomull/snake that referenced this issue Jun 2, 2019
Both had to happen at the same time, because recent nightly compilers
don't have an std::await macro for Tokio to take over, and thus don't
compile tokio's async-await-preview feature.  Per tokio-rs/tokio#1087 (comment),
development is being done on the master branch instead.

There are a couple new `Box`es being made since I changed some .map()s
into more readable async closures, which are unfortunately never
`Unpin`.

I also hit an internal compiler error in
	rustc 1.37.0-nightly (7840a0b75 2019-05-31)
by missing the `mut` in the function signature of X11Events::read_exact.

I probably would have been completely lost without
https://rust-lang-nursery.github.io/futures-rs/blog/2019/04/18/compatibility-layer.html.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants