about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTaylor Cramer <cramertj@google.com>2019-04-18 12:55:23 -0700
committerTaylor Cramer <cramertj@google.com>2019-05-07 14:45:53 -0700
commitfe8760cb848d45f5c83b41e689878b893b74e45d (patch)
tree8042688119098da68322461411aa8c44cfdcb3d4 /src/test
parentc3b8ab5199af4a3c11d14b0cbdb17a641e8eee71 (diff)
downloadrust-fe8760cb848d45f5c83b41e689878b893b74e45d.tar.gz
rust-fe8760cb848d45f5c83b41e689878b893b74e45d.zip
Implement built-in await syntax
Adds support for .await under the existing async_await feature gate.
Moves macro-like await! syntax to the await_macro feature gate.
Removes support for `await` as a non-keyword under the `async_await`
feature.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/async-await.rs36
-rw-r--r--src/test/run-pass/await-macro.rs199
-rw-r--r--src/test/run-pass/issue-55809.rs10
-rw-r--r--src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs36
-rw-r--r--src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr88
-rw-r--r--src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs16
-rw-r--r--src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs27
-rw-r--r--src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr80
-rw-r--r--src/test/ui/await-keyword/2018-edition-error.rs11
-rw-r--r--src/test/ui/await-keyword/2018-edition-error.stderr46
-rw-r--r--src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs16
-rw-r--r--src/test/ui/await-keyword/post_expansion_error.rs2
-rw-r--r--src/test/ui/await-keyword/post_expansion_error.stderr6
-rw-r--r--src/test/ui/feature-gate/await-macro.rs12
-rw-r--r--src/test/ui/feature-gate/await-macro.stderr12
-rw-r--r--src/test/ui/generator/unresolved_type_param.rs11
-rw-r--r--src/test/ui/generator/unresolved_type_param.stderr13
-rw-r--r--src/test/ui/issues/issue-51719.rs11
-rw-r--r--src/test/ui/issues/issue-51719.stderr8
-rw-r--r--src/test/ui/issues/issue-51751.rs13
-rw-r--r--src/test/ui/issues/issue-51751.stderr8
21 files changed, 567 insertions, 94 deletions
diff --git a/src/test/run-pass/async-await.rs b/src/test/run-pass/async-await.rs
index e1b4328debd..49fd8b8b1ce 100644
--- a/src/test/run-pass/async-await.rs
+++ b/src/test/run-pass/async-await.rs
@@ -1,7 +1,7 @@
 // edition:2018
 // aux-build:arc_wake.rs
 
-#![feature(async_await, await_macro)]
+#![feature(async_await)]
 
 extern crate arc_wake;
 
@@ -46,14 +46,14 @@ impl Future for WakeOnceThenComplete {
 
 fn async_block(x: u8) -> impl Future<Output = u8> {
     async move {
-        await!(wake_and_yield_once());
+        wake_and_yield_once().await;
         x
     }
 }
 
 fn async_block_with_borrow_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a {
     async move {
-        await!(wake_and_yield_once());
+        wake_and_yield_once().await;
         *x
     }
 }
@@ -61,43 +61,43 @@ fn async_block_with_borrow_named_lifetime<'a>(x: &'a u8) -> impl Future<Output =
 fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
     async move {
         let future = async {
-            await!(wake_and_yield_once());
+            wake_and_yield_once().await;
             x
         };
-        await!(future)
+        future.await
     }
 }
 
 fn async_closure(x: u8) -> impl Future<Output = u8> {
     (async move |x: u8| -> u8 {
-        await!(wake_and_yield_once());
+        wake_and_yield_once().await;
         x
     })(x)
 }
 
 async fn async_fn(x: u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     x
 }
 
 async fn generic_async_fn<T>(x: T) -> T {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     x
 }
 
 async fn async_fn_with_borrow(x: &u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     *x
 }
 
 async fn async_fn_with_borrow_named_lifetime<'a>(x: &'a u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     *x
 }
 
 fn async_fn_with_impl_future_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a {
     async move {
-        await!(wake_and_yield_once());
+        wake_and_yield_once().await;
         *x
     }
 }
@@ -110,18 +110,18 @@ async fn async_fn_multiple_args(x: &u8, _y: &u8) -> u8 {
 */
 
 async fn async_fn_multiple_args_named_lifetime<'a>(x: &'a u8, _y: &'a u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     *x
 }
 
 fn async_fn_with_internal_borrow(y: u8) -> impl Future<Output = u8> {
     async move {
-        await!(async_fn_with_borrow_named_lifetime(&y))
+        async_fn_with_borrow_named_lifetime(&y).await
     }
 }
 
 unsafe async fn unsafe_async_fn(x: u8) -> u8 {
-    await!(wake_and_yield_once());
+    wake_and_yield_once().await;
     x
 }
 
@@ -134,7 +134,7 @@ trait Bar {
 impl Foo {
     async fn async_method(x: u8) -> u8 {
         unsafe {
-            await!(unsafe_async_fn(x))
+            unsafe_async_fn(x).await
         }
     }
 }
@@ -165,7 +165,7 @@ fn main() {
         ($($fn_name:expr,)*) => { $(
             test_future_yields_once_then_returns(|x| {
                 async move {
-                    await!($fn_name(&x))
+                    $fn_name(&x).await
                 }
             });
         )* }
@@ -181,7 +181,7 @@ fn main() {
         Foo::async_method,
         |x| {
             async move {
-                unsafe { await!(unsafe_async_fn(x)) }
+                unsafe { unsafe_async_fn(x).await }
             }
         },
     }
@@ -192,7 +192,7 @@ fn main() {
         async_fn_with_impl_future_named_lifetime,
         |x| {
             async move {
-                await!(async_fn_multiple_args_named_lifetime(x, x))
+                async_fn_multiple_args_named_lifetime(x, x).await
             }
         },
     }
diff --git a/src/test/run-pass/await-macro.rs b/src/test/run-pass/await-macro.rs
new file mode 100644
index 00000000000..e1b4328debd
--- /dev/null
+++ b/src/test/run-pass/await-macro.rs
@@ -0,0 +1,199 @@
+// edition:2018
+// aux-build:arc_wake.rs
+
+#![feature(async_await, await_macro)]
+
+extern crate arc_wake;
+
+use std::pin::Pin;
+use std::future::Future;
+use std::sync::{
+    Arc,
+    atomic::{self, AtomicUsize},
+};
+use std::task::{Context, Poll};
+use arc_wake::ArcWake;
+
+struct Counter {
+    wakes: AtomicUsize,
+}
+
+impl ArcWake for Counter {
+    fn wake(self: Arc<Self>) {
+        Self::wake_by_ref(&self)
+    }
+    fn wake_by_ref(arc_self: &Arc<Self>) {
+        arc_self.wakes.fetch_add(1, atomic::Ordering::SeqCst);
+    }
+}
+
+struct WakeOnceThenComplete(bool);
+
+fn wake_and_yield_once() -> WakeOnceThenComplete { WakeOnceThenComplete(false) }
+
+impl Future for WakeOnceThenComplete {
+    type Output = ();
+    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
+        if self.0 {
+            Poll::Ready(())
+        } else {
+            cx.waker().wake_by_ref();
+            self.0 = true;
+            Poll::Pending
+        }
+    }
+}
+
+fn async_block(x: u8) -> impl Future<Output = u8> {
+    async move {
+        await!(wake_and_yield_once());
+        x
+    }
+}
+
+fn async_block_with_borrow_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a {
+    async move {
+        await!(wake_and_yield_once());
+        *x
+    }
+}
+
+fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
+    async move {
+        let future = async {
+            await!(wake_and_yield_once());
+            x
+        };
+        await!(future)
+    }
+}
+
+fn async_closure(x: u8) -> impl Future<Output = u8> {
+    (async move |x: u8| -> u8 {
+        await!(wake_and_yield_once());
+        x
+    })(x)
+}
+
+async fn async_fn(x: u8) -> u8 {
+    await!(wake_and_yield_once());
+    x
+}
+
+async fn generic_async_fn<T>(x: T) -> T {
+    await!(wake_and_yield_once());
+    x
+}
+
+async fn async_fn_with_borrow(x: &u8) -> u8 {
+    await!(wake_and_yield_once());
+    *x
+}
+
+async fn async_fn_with_borrow_named_lifetime<'a>(x: &'a u8) -> u8 {
+    await!(wake_and_yield_once());
+    *x
+}
+
+fn async_fn_with_impl_future_named_lifetime<'a>(x: &'a u8) -> impl Future<Output = u8> + 'a {
+    async move {
+        await!(wake_and_yield_once());
+        *x
+    }
+}
+
+/* FIXME(cramertj) support when `existential type T<'a, 'b>:;` works
+async fn async_fn_multiple_args(x: &u8, _y: &u8) -> u8 {
+    await!(wake_and_yield_once());
+    *x
+}
+*/
+
+async fn async_fn_multiple_args_named_lifetime<'a>(x: &'a u8, _y: &'a u8) -> u8 {
+    await!(wake_and_yield_once());
+    *x
+}
+
+fn async_fn_with_internal_borrow(y: u8) -> impl Future<Output = u8> {
+    async move {
+        await!(async_fn_with_borrow_named_lifetime(&y))
+    }
+}
+
+unsafe async fn unsafe_async_fn(x: u8) -> u8 {
+    await!(wake_and_yield_once());
+    x
+}
+
+struct Foo;
+
+trait Bar {
+    fn foo() {}
+}
+
+impl Foo {
+    async fn async_method(x: u8) -> u8 {
+        unsafe {
+            await!(unsafe_async_fn(x))
+        }
+    }
+}
+
+fn test_future_yields_once_then_returns<F, Fut>(f: F)
+where
+    F: FnOnce(u8) -> Fut,
+    Fut: Future<Output = u8>,
+{
+    let mut fut = Box::pin(f(9));
+    let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) });
+    let waker = ArcWake::into_waker(counter.clone());
+    let mut cx = Context::from_waker(&waker);
+    assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst));
+    assert_eq!(Poll::Pending, fut.as_mut().poll(&mut cx));
+    assert_eq!(1, counter.wakes.load(atomic::Ordering::SeqCst));
+    assert_eq!(Poll::Ready(9), fut.as_mut().poll(&mut cx));
+}
+
+fn main() {
+    macro_rules! test {
+        ($($fn_name:expr,)*) => { $(
+            test_future_yields_once_then_returns($fn_name);
+        )* }
+    }
+
+    macro_rules! test_with_borrow {
+        ($($fn_name:expr,)*) => { $(
+            test_future_yields_once_then_returns(|x| {
+                async move {
+                    await!($fn_name(&x))
+                }
+            });
+        )* }
+    }
+
+    test! {
+        async_block,
+        async_nonmove_block,
+        async_closure,
+        async_fn,
+        generic_async_fn,
+        async_fn_with_internal_borrow,
+        Foo::async_method,
+        |x| {
+            async move {
+                unsafe { await!(unsafe_async_fn(x)) }
+            }
+        },
+    }
+    test_with_borrow! {
+        async_block_with_borrow_named_lifetime,
+        async_fn_with_borrow,
+        async_fn_with_borrow_named_lifetime,
+        async_fn_with_impl_future_named_lifetime,
+        |x| {
+            async move {
+                await!(async_fn_multiple_args_named_lifetime(x, x))
+            }
+        },
+    }
+}
diff --git a/src/test/run-pass/issue-55809.rs b/src/test/run-pass/issue-55809.rs
index 12be6582a21..b7e60b773b4 100644
--- a/src/test/run-pass/issue-55809.rs
+++ b/src/test/run-pass/issue-55809.rs
@@ -1,7 +1,7 @@
 // edition:2018
 // run-pass
 
-#![feature(async_await, await_macro)]
+#![feature(async_await)]
 
 trait Foo { }
 
@@ -14,15 +14,15 @@ async fn foo_async<T>(_v: T) -> u8 where T: Foo {
 }
 
 async fn bad<T>(v: T) -> u8 where T: Foo {
-    await!(foo_async(v))
+    foo_async(v).await
 }
 
 async fn async_main() {
     let mut v = ();
 
-    let _ = await!(bad(&mut v));
-    let _ = await!(foo_async(&mut v));
-    let _ = await!(bad(v));
+    let _ = bad(&mut v).await;
+    let _ = foo_async(&mut v).await;
+    let _ = bad(v).await;
 }
 
 fn main() {
diff --git a/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs b/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs
new file mode 100644
index 00000000000..c4f3f3edc48
--- /dev/null
+++ b/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.rs
@@ -0,0 +1,36 @@
+#![feature(async_await, await_macro)]
+#![allow(non_camel_case_types)]
+#![deny(keyword_idents)]
+
+mod outer_mod {
+    pub mod await { //~ ERROR `await` is a keyword in the 2018 edition
+    //~^ WARN this was previously accepted by the compiler
+        pub struct await; //~ ERROR `await` is a keyword in the 2018 edition
+        //~^ WARN this was previously accepted by the compiler
+    }
+}
+use outer_mod::await::await; //~ ERROR `await` is a keyword in the 2018 edition
+//~^ ERROR `await` is a keyword in the 2018 edition
+//~^^ WARN this was previously accepted by the compiler
+//~^^^ WARN this was previously accepted by the compiler
+
+struct Foo { await: () }
+//~^ ERROR `await` is a keyword in the 2018 edition
+//~^^ WARN this was previously accepted by the compiler
+
+impl Foo { fn await() {} }
+//~^ ERROR `await` is a keyword in the 2018 edition
+//~^^ WARN this was previously accepted by the compiler
+
+macro_rules! await {
+//~^ ERROR `await` is a keyword in the 2018 edition
+//~^^ WARN this was previously accepted by the compiler
+    () => {}
+}
+
+fn main() {
+    match await { await => {} } //~ ERROR `await` is a keyword in the 2018 edition
+    //~^ ERROR `await` is a keyword in the 2018 edition
+    //~^^ WARN this was previously accepted by the compiler
+    //~^^^ WARN this was previously accepted by the compiler
+}
diff --git a/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr b/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr
new file mode 100644
index 00000000000..067ecd6a513
--- /dev/null
+++ b/src/test/ui/await-keyword/2015-edition-error-in-non-macro-position.stderr
@@ -0,0 +1,88 @@
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:6:13
+   |
+LL |     pub mod await {
+   |             ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+note: lint level defined here
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:3:9
+   |
+LL | #![deny(keyword_idents)]
+   |         ^^^^^^^^^^^^^^
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:8:20
+   |
+LL |         pub struct await;
+   |                    ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:12:16
+   |
+LL | use outer_mod::await::await;
+   |                ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:12:23
+   |
+LL | use outer_mod::await::await;
+   |                       ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:17:14
+   |
+LL | struct Foo { await: () }
+   |              ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:21:15
+   |
+LL | impl Foo { fn await() {} }
+   |               ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:25:14
+   |
+LL | macro_rules! await {
+   |              ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:32:11
+   |
+LL |     match await { await => {} }
+   |           ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: `await` is a keyword in the 2018 edition
+  --> $DIR/2015-edition-error-in-non-macro-position.rs:32:19
+   |
+LL |     match await { await => {} }
+   |                   ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
+   = note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
+
+error: aborting due to 9 previous errors
+
diff --git a/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs b/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs
deleted file mode 100644
index 92c60e7d6ee..00000000000
--- a/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// compile-pass
-
-#![feature(async_await)]
-#![allow(non_camel_case_types)]
-#![deny(keyword_idents)]
-
-mod outer_mod {
-    pub mod await {
-        pub struct await;
-    }
-}
-use outer_mod::await::await;
-
-fn main() {
-    match await { await => {} }
-}
diff --git a/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs b/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs
new file mode 100644
index 00000000000..b2e8e4be172
--- /dev/null
+++ b/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.rs
@@ -0,0 +1,27 @@
+// edition:2018
+
+#![allow(non_camel_case_types)]
+#![feature(async_await, await_macro)]
+
+mod outer_mod {
+    pub mod await { //~ ERROR expected identifier, found reserved keyword `await`
+        pub struct await; //~ ERROR expected identifier, found reserved keyword `await`
+    }
+}
+use self::outer_mod::await::await; //~ ERROR expected identifier, found reserved keyword `await`
+//~^ ERROR expected identifier, found reserved keyword `await`
+
+struct Foo { await: () }
+//~^ ERROR expected identifier, found reserved keyword `await`
+
+impl Foo { fn await() {} }
+//~^ ERROR expected identifier, found reserved keyword `await`
+
+macro_rules! await {
+//~^ ERROR expected identifier, found reserved keyword `await`
+    () => {}
+}
+
+fn main() {
+    match await { await => () } //~ ERROR expected `!`, found `{`
+}
diff --git a/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr b/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr
new file mode 100644
index 00000000000..076a31bd9ce
--- /dev/null
+++ b/src/test/ui/await-keyword/2018-edition-error-in-non-macro-position.stderr
@@ -0,0 +1,80 @@
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:7:13
+   |
+LL |     pub mod await {
+   |             ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL |     pub mod r#await {
+   |             ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:8:20
+   |
+LL |         pub struct await;
+   |                    ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL |         pub struct r#await;
+   |                    ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:11:22
+   |
+LL | use self::outer_mod::await::await;
+   |                      ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | use self::outer_mod::r#await::await;
+   |                      ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:11:29
+   |
+LL | use self::outer_mod::await::await;
+   |                             ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | use self::outer_mod::await::r#await;
+   |                             ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:14:14
+   |
+LL | struct Foo { await: () }
+   |              ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | struct Foo { r#await: () }
+   |              ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:17:15
+   |
+LL | impl Foo { fn await() {} }
+   |               ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | impl Foo { fn r#await() {} }
+   |               ^^^^^^^
+
+error: expected identifier, found reserved keyword `await`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:20:14
+   |
+LL | macro_rules! await {
+   |              ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | macro_rules! r#await {
+   |              ^^^^^^^
+
+error: expected `!`, found `{`
+  --> $DIR/2018-edition-error-in-non-macro-position.rs:26:17
+   |
+LL |     match await { await => () }
+   |     -----       ^ expected `!`
+   |     |
+   |     while parsing this match expression
+
+error: aborting due to 8 previous errors
+
diff --git a/src/test/ui/await-keyword/2018-edition-error.rs b/src/test/ui/await-keyword/2018-edition-error.rs
index 7ba3382ddf1..e0b2962ce97 100644
--- a/src/test/ui/await-keyword/2018-edition-error.rs
+++ b/src/test/ui/await-keyword/2018-edition-error.rs
@@ -2,14 +2,13 @@
 #![allow(non_camel_case_types)]
 
 mod outer_mod {
-    pub mod await { //~ ERROR `await` is a keyword
-        pub struct await; //~ ERROR `await` is a keyword
+    pub mod await { //~ ERROR expected identifier
+        pub struct await; //~ ERROR expected identifier
     }
 }
-use self::outer_mod::await::await; //~ ERROR `await` is a keyword
-    //~^ ERROR `await` is a keyword
+use self::outer_mod::await::await; //~ ERROR expected identifier
+    //~^ ERROR expected identifier, found reserved keyword `await`
 
 fn main() {
-    match await { await => () } //~ ERROR `await` is a keyword
-    //~^ ERROR `await` is a keyword
+    match await { await => () } //~ ERROR expected `!`, found `{`
 }
diff --git a/src/test/ui/await-keyword/2018-edition-error.stderr b/src/test/ui/await-keyword/2018-edition-error.stderr
index 67ff6c5675a..c8bf9b42ca5 100644
--- a/src/test/ui/await-keyword/2018-edition-error.stderr
+++ b/src/test/ui/await-keyword/2018-edition-error.stderr
@@ -1,38 +1,50 @@
-error[E0721]: `await` is a keyword in the 2018 edition
+error: expected identifier, found reserved keyword `await`
   --> $DIR/2018-edition-error.rs:5:13
    |
 LL |     pub mod await {
-   |             ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |             ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL |     pub mod r#await {
+   |             ^^^^^^^
 
-error[E0721]: `await` is a keyword in the 2018 edition
+error: expected identifier, found reserved keyword `await`
   --> $DIR/2018-edition-error.rs:6:20
    |
 LL |         pub struct await;
-   |                    ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |                    ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL |         pub struct r#await;
+   |                    ^^^^^^^
 
-error[E0721]: `await` is a keyword in the 2018 edition
+error: expected identifier, found reserved keyword `await`
   --> $DIR/2018-edition-error.rs:9:22
    |
 LL | use self::outer_mod::await::await;
-   |                      ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |                      ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
+   |
+LL | use self::outer_mod::r#await::await;
+   |                      ^^^^^^^
 
-error[E0721]: `await` is a keyword in the 2018 edition
+error: expected identifier, found reserved keyword `await`
   --> $DIR/2018-edition-error.rs:9:29
    |
 LL | use self::outer_mod::await::await;
-   |                             ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
-
-error[E0721]: `await` is a keyword in the 2018 edition
-  --> $DIR/2018-edition-error.rs:13:11
+   |                             ^^^^^ expected identifier, found reserved keyword
+help: you can escape reserved keywords to use them as identifiers
    |
-LL |     match await { await => () }
-   |           ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+LL | use self::outer_mod::await::r#await;
+   |                             ^^^^^^^
 
-error[E0721]: `await` is a keyword in the 2018 edition
-  --> $DIR/2018-edition-error.rs:13:19
+error: expected `!`, found `{`
+  --> $DIR/2018-edition-error.rs:13:17
    |
 LL |     match await { await => () }
-   |                   ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |     -----       ^ expected `!`
+   |     |
+   |     while parsing this match expression
 
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs b/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs
deleted file mode 100644
index 52d32c83510..00000000000
--- a/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// compile-pass
-// edition:2018
-
-#![allow(non_camel_case_types)]
-#![feature(async_await)]
-
-mod outer_mod {
-    pub mod await {
-        pub struct await;
-    }
-}
-use self::outer_mod::await::await;
-
-fn main() {
-    match await { await => () }
-}
diff --git a/src/test/ui/await-keyword/post_expansion_error.rs b/src/test/ui/await-keyword/post_expansion_error.rs
index 96dd48052de..b4c899b0d02 100644
--- a/src/test/ui/await-keyword/post_expansion_error.rs
+++ b/src/test/ui/await-keyword/post_expansion_error.rs
@@ -6,5 +6,5 @@ macro_rules! r#await {
 
 fn main() {
     await!()
-    //~^ ERROR `await` is a keyword
+    //~^ ERROR expected expression, found `)`
 }
diff --git a/src/test/ui/await-keyword/post_expansion_error.stderr b/src/test/ui/await-keyword/post_expansion_error.stderr
index 9483f774227..0996c38b3b6 100644
--- a/src/test/ui/await-keyword/post_expansion_error.stderr
+++ b/src/test/ui/await-keyword/post_expansion_error.stderr
@@ -1,8 +1,8 @@
-error[E0721]: `await` is a keyword in the 2018 edition
-  --> $DIR/post_expansion_error.rs:8:5
+error: expected expression, found `)`
+  --> $DIR/post_expansion_error.rs:8:12
    |
 LL |     await!()
-   |     ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
+   |            ^ expected expression
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/feature-gate/await-macro.rs b/src/test/ui/feature-gate/await-macro.rs
new file mode 100644
index 00000000000..291db9ba413
--- /dev/null
+++ b/src/test/ui/feature-gate/await-macro.rs
@@ -0,0 +1,12 @@
+// gate-test-await_macro
+// edition:2018
+
+#![feature(async_await)]
+
+async fn bar() {}
+
+async fn foo() {
+    await!(bar()); //~ ERROR `await!(<expr>)` macro syntax is unstable, and will soon be removed
+}
+
+fn main() {}
diff --git a/src/test/ui/feature-gate/await-macro.stderr b/src/test/ui/feature-gate/await-macro.stderr
new file mode 100644
index 00000000000..b6833655f6d
--- /dev/null
+++ b/src/test/ui/feature-gate/await-macro.stderr
@@ -0,0 +1,12 @@
+error[E0658]: `await!(<expr>)` macro syntax is unstable, and will soon be removed in favor of `<expr>.await` syntax.
+  --> $DIR/await-macro.rs:9:5
+   |
+LL |     await!(bar());
+   |     ^^^^^
+   |
+   = note: for more information, see https://github.com/rust-lang/rust/issues/50547
+   = help: add #![feature(await_macro)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/generator/unresolved_type_param.rs b/src/test/ui/generator/unresolved_type_param.rs
index f49369b125f..77174b03217 100644
--- a/src/test/ui/generator/unresolved_type_param.rs
+++ b/src/test/ui/generator/unresolved_type_param.rs
@@ -2,13 +2,14 @@
 // Error message should pinpoint the type parameter T as needing to be bound
 // (rather than give a general error message)
 // edition:2018
-#![feature(futures_api, async_await, await_macro)]
+#![feature(async_await)]
 async fn bar<T>() -> () {}
 
 async fn foo() {
-        await!(bar());
-        //~^ ERROR type inside generator must be known in this context
-        //~| NOTE cannot infer type for `T`
-        //~| NOTE the type is part of the generator because of this `yield`
+    bar().await;
+    //~^ ERROR type inside generator must be known in this context
+    //~| NOTE cannot infer type for `T`
+    //~| NOTE the type is part of the generator because of this `yield`
+    //~| NOTE in this expansion of desugaring of `await`
 }
 fn main() {}
diff --git a/src/test/ui/generator/unresolved_type_param.stderr b/src/test/ui/generator/unresolved_type_param.stderr
index 57ccdda3f43..afb9adf4c77 100644
--- a/src/test/ui/generator/unresolved_type_param.stderr
+++ b/src/test/ui/generator/unresolved_type_param.stderr
@@ -1,15 +1,14 @@
 error[E0698]: type inside generator must be known in this context
-  --> $DIR/unresolved_type_param.rs:9:16
+  --> $DIR/unresolved_type_param.rs:9:5
    |
-LL |         await!(bar());
-   |                ^^^ cannot infer type for `T`
+LL |     bar().await;
+   |     ^^^ cannot infer type for `T`
    |
 note: the type is part of the generator because of this `yield`
-  --> $DIR/unresolved_type_param.rs:9:9
+  --> $DIR/unresolved_type_param.rs:9:5
    |
-LL |         await!(bar());
-   |         ^^^^^^^^^^^^^^
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+LL |     bar().await;
+   |     ^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-51719.rs b/src/test/ui/issues/issue-51719.rs
new file mode 100644
index 00000000000..2c02ac01142
--- /dev/null
+++ b/src/test/ui/issues/issue-51719.rs
@@ -0,0 +1,11 @@
+// edition:2018
+//
+// Tests that the .await syntax can't be used to make a generator
+
+#![feature(async_await)]
+
+async fn foo() {}
+
+fn make_generator() {
+    let _gen = || foo.await; //~ ERROR `await` is only allowed inside `async` functions and blocks
+}
diff --git a/src/test/ui/issues/issue-51719.stderr b/src/test/ui/issues/issue-51719.stderr
new file mode 100644
index 00000000000..768909b66ec
--- /dev/null
+++ b/src/test/ui/issues/issue-51719.stderr
@@ -0,0 +1,8 @@
+error[E0728]: `await` is only allowed inside `async` functions and blocks
+  --> $DIR/issue-51719.rs:10:19
+   |
+LL |     let _gen = || foo.await;
+   |                   ^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/issues/issue-51751.rs b/src/test/ui/issues/issue-51751.rs
new file mode 100644
index 00000000000..7afd7ecc826
--- /dev/null
+++ b/src/test/ui/issues/issue-51751.rs
@@ -0,0 +1,13 @@
+// edition:2018
+
+#![feature(async_await)]
+
+async fn inc(limit: i64) -> i64 {
+    limit + 1
+}
+
+fn main() {
+    let result = inc(10000);
+    let finished = result.await;
+    //~^ ERROR `await` is only allowed inside `async` functions and blocks
+}
diff --git a/src/test/ui/issues/issue-51751.stderr b/src/test/ui/issues/issue-51751.stderr
new file mode 100644
index 00000000000..0c4cb034a93
--- /dev/null
+++ b/src/test/ui/issues/issue-51751.stderr
@@ -0,0 +1,8 @@
+error[E0728]: `await` is only allowed inside `async` functions and blocks
+  --> $DIR/issue-51751.rs:11:20
+   |
+LL |     let finished = result.await;
+   |                    ^^^^^^^^^^^^
+
+error: aborting due to previous error
+