about summary refs log tree commit diff
path: root/tests/ui/parser
diff options
context:
space:
mode:
authordarklyspaced <srohanjd@gmail.com>2023-08-07 22:10:21 +0800
committerdarklyspaced <srohanjd@gmail.com>2023-08-07 22:10:21 +0800
commit6d256d9d0ec3a42084ae0675139680e71657aeeb (patch)
tree59360bcf2bdb7ad1800f54ff47e9c6205e12ec2c /tests/ui/parser
parentadb15a20ac99024ea90b28abd5af12f438fa2a20 (diff)
downloadrust-6d256d9d0ec3a42084ae0675139680e71657aeeb.tar.gz
rust-6d256d9d0ec3a42084ae0675139680e71657aeeb.zip
test infra added
Diffstat (limited to 'tests/ui/parser')
-rw-r--r--tests/ui/parser/issue-113203.rs8
-rw-r--r--tests/ui/parser/issue-113203.stderr30
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/parser/issue-113203.rs b/tests/ui/parser/issue-113203.rs
new file mode 100644
index 00000000000..eeefd941da4
--- /dev/null
+++ b/tests/ui/parser/issue-113203.rs
@@ -0,0 +1,8 @@
+// Checks what happens when we attempt to use the await keyword as a prefix. Span
+// incorrectly emitted an `.await` in E0277 which does not exist
+// edition:2018
+fn main() {
+    await {}()
+    //~^ ERROR `await` is only allowed inside `async` functions and blocks
+    //~| ERROR incorrect use of `await`
+}
diff --git a/tests/ui/parser/issue-113203.stderr b/tests/ui/parser/issue-113203.stderr
new file mode 100644
index 00000000000..f205f4addcd
--- /dev/null
+++ b/tests/ui/parser/issue-113203.stderr
@@ -0,0 +1,30 @@
+error: incorrect use of `await`
+  --> $DIR/issue-113203.rs:5:5
+   |
+LL |     await {}()
+   |     ^^^^^^^^ help: `await` is a postfix operation: `{}.await`
+
+error[E0728]: `await` is only allowed inside `async` functions and blocks
+  --> $DIR/issue-113203.rs:5:5
+   |
+LL | fn main() {
+   |    ---- this is not `async`
+LL |     await {}()
+   |     ^^^^^ only allowed inside `async` functions and blocks
+
+error[E0277]: `()` is not a future
+  --> $DIR/issue-113203.rs:5:5
+   |
+LL |     await {}()
+   |     ^^^^^   - help: remove the `.await`
+   |     |
+   |     `()` is not a future
+   |
+   = 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: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0277, E0728.
+For more information about an error, try `rustc --explain E0277`.