about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMilo <50248166+Milo123459@users.noreply.github.com>2023-09-26 16:02:05 +0000
committerMilo <50248166+Milo123459@users.noreply.github.com>2023-09-26 20:15:28 +0000
commit35f9345076b80a26c7c96f18fb95f69adbee2375 (patch)
tree2ed928f35bbe87901bc09cb503ddd118fa08fe17
parent6710e3312d54f03f6462481199b9e72367a2568b (diff)
downloadrust-35f9345076b80a26c7c96f18fb95f69adbee2375.tar.gz
rust-35f9345076b80a26c7c96f18fb95f69adbee2375.zip
add test
fix tidy

remove dir
-rw-r--r--tests/ui/async-await/const-async-fn-in-main.rs7
-rw-r--r--tests/ui/async-await/const-async-fn-in-main.stderr11
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/async-await/const-async-fn-in-main.rs b/tests/ui/async-await/const-async-fn-in-main.rs
new file mode 100644
index 00000000000..5d1aa4d83f3
--- /dev/null
+++ b/tests/ui/async-await/const-async-fn-in-main.rs
@@ -0,0 +1,7 @@
+// edition:2021
+// Check what happens when a const async fn is in the main function (#102796)
+
+fn main() {
+    const async fn a() {}
+//~^ ERROR functions cannot be both `const` and `async`
+}
diff --git a/tests/ui/async-await/const-async-fn-in-main.stderr b/tests/ui/async-await/const-async-fn-in-main.stderr
new file mode 100644
index 00000000000..10b15170922
--- /dev/null
+++ b/tests/ui/async-await/const-async-fn-in-main.stderr
@@ -0,0 +1,11 @@
+error: functions cannot be both `const` and `async`
+  --> $DIR/const-async-fn-in-main.rs:5:5
+   |
+LL |     const async fn a() {}
+   |     ^^^^^-^^^^^----------
+   |     |     |
+   |     |     `async` because of this
+   |     `const` because of this
+
+error: aborting due to previous error
+