about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir2
-rw-r--r--tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr10
-rw-r--r--tests/ui/async-await/unnecessary-await.rs20
-rw-r--r--tests/ui/async-await/unnecessary-await.stderr32
4 files changed, 57 insertions, 7 deletions
diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir
index cefb8ff3ca9..a9d1477b9fe 100644
--- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir
+++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir
@@ -12,7 +12,7 @@
         _1: GeneratorSavedTy {
             ty: impl std::future::Future<Output = ()>,
             source_info: SourceInfo {
-                span: $DIR/async_await.rs:16:8: 16:14 (#10),
+                span: $DIR/async_await.rs:16:9: 16:14 (#10),
                 scope: scope[0],
             },
             ignore_for_traits: false,
diff --git a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
index 59630e837b7..7b03e56662a 100644
--- a/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
+++ b/tests/ui/async-await/await-keyword/incorrect-syntax-suggestions.stderr
@@ -143,7 +143,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
 LL | fn foo9() -> Result<(), ()> {
    |    ---- this is not `async`
 LL |     let _ = await bar();
-   |             ^^^^^^^^^^^ only allowed inside `async` functions and blocks
+   |             ^^^^^ only allowed inside `async` functions and blocks
 
 error[E0728]: `await` is only allowed inside `async` functions and blocks
   --> $DIR/incorrect-syntax-suggestions.rs:57:13
@@ -151,7 +151,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
 LL | fn foo10() -> Result<(), ()> {
    |    ----- this is not `async`
 LL |     let _ = await? bar();
-   |             ^^^^^^^^^^^^ only allowed inside `async` functions and blocks
+   |             ^^^^^ only allowed inside `async` functions and blocks
 
 error[E0728]: `await` is only allowed inside `async` functions and blocks
   --> $DIR/incorrect-syntax-suggestions.rs:66:14
@@ -159,7 +159,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
 LL | fn foo12() -> Result<(), ()> {
    |    ----- this is not `async`
 LL |     let _ = (await bar())?;
-   |              ^^^^^^^^^^^ only allowed inside `async` functions and blocks
+   |              ^^^^^ only allowed inside `async` functions and blocks
 
 error[E0728]: `await` is only allowed inside `async` functions and blocks
   --> $DIR/incorrect-syntax-suggestions.rs:71:19
@@ -215,7 +215,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
 LL |     fn foo() -> Result<(), ()> {
    |        --- this is not `async`
 LL |         let _ = await!(bar())?;
-   |                 ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
+   |                 ^^^^^ only allowed inside `async` functions and blocks
 
 error[E0728]: `await` is only allowed inside `async` functions and blocks
   --> $DIR/incorrect-syntax-suggestions.rs:121:17
@@ -223,7 +223,7 @@ error[E0728]: `await` is only allowed inside `async` functions and blocks
 LL |     let foo = || {
    |               -- this is not `async`
 LL |         let _ = await!(bar())?;
-   |                 ^^^^^^^^^^^^^ only allowed inside `async` functions and blocks
+   |                 ^^^^^ only allowed inside `async` functions and blocks
 
 error: aborting due to 33 previous errors
 
diff --git a/tests/ui/async-await/unnecessary-await.rs b/tests/ui/async-await/unnecessary-await.rs
index 24673777b80..cd1e2871432 100644
--- a/tests/ui/async-await/unnecessary-await.rs
+++ b/tests/ui/async-await/unnecessary-await.rs
@@ -11,4 +11,24 @@ async fn baz() -> std::io::Result<()> {
     std::io::Result::Ok(())
 }
 
+macro_rules! e {
+    () => {
+        ()
+    };
+}
+
+macro_rules! f {
+    ($expr:expr) => {
+        $expr.await
+        //~^ ERROR `()` is not a future
+    };
+}
+
+async fn with_macros() {
+    e!().await;
+    //~^ ERROR `()` is not a future
+
+    f!(());
+}
+
 fn main() {}
diff --git a/tests/ui/async-await/unnecessary-await.stderr b/tests/ui/async-await/unnecessary-await.stderr
index f1b358ed68a..9a2a035b2dd 100644
--- a/tests/ui/async-await/unnecessary-await.stderr
+++ b/tests/ui/async-await/unnecessary-await.stderr
@@ -19,6 +19,36 @@ help: alternatively, consider making `fn boo` asynchronous
 LL | async fn boo() {}
    | +++++
 
-error: aborting due to previous error
+error[E0277]: `()` is not a future
+  --> $DIR/unnecessary-await.rs:28:10
+   |
+LL |     e!().await;
+   |         -^^^^^
+   |         ||
+   |         |`()` is not a future
+   |         help: remove the `.await`
+   |
+   = help: the trait `Future` is not implemented for `()`
+   = note: () must be a future or must implement `IntoFuture` to be awaited
+   = note: required for `()` to implement `IntoFuture`
+
+error[E0277]: `()` is not a future
+  --> $DIR/unnecessary-await.rs:22:15
+   |
+LL |         $expr.await
+   |               ^^^^^
+   |               |
+   |               `()` is not a future
+   |               remove the `.await`
+...
+LL |     f!(());
+   |     ------ in this macro invocation
+   |
+   = help: the trait `Future` is not implemented for `()`
+   = note: () must be a future or must implement `IntoFuture` to be awaited
+   = note: required for `()` to implement `IntoFuture`
+   = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0277`.